effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Prims.Tot | val map_dec (#a #b: _) (l: list a) (f: (x: a{x << l} -> b)) : Tot (list b) (decreases l) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f | val map_dec (#a #b: _) (l: list a) (f: (x: a{x << l} -> b)) : Tot (list b) (decreases l)
let rec map_dec #a #b (l: list a) (f: (x: a{x << l} -> b)) : Tot (list b) (decreases l) = | false | null | false | match l with
| [] -> []
| x :: xs -> f x :: map_dec xs f | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total",
""
] | [
"Prims.list",
"Prims.precedes",
"Prims.Nil",
"Prims.Cons",
"FStar.Reflection.Typing.map_dec"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l) | false | false | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val map_dec (#a #b: _) (l: list a) (f: (x: a{x << l} -> b)) : Tot (list b) (decreases l) | [
"recursion"
] | FStar.Reflection.Typing.map_dec | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list a -> f: (x: a{x << l} -> b) -> Prims.Tot (Prims.list b) | {
"end_col": 32,
"end_line": 55,
"start_col": 2,
"start_line": 53
} |
Prims.Tot | val mk_binder (pp_name: pp_name_t) (ty: term) (q: aqualv) : binder | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty} | val mk_binder (pp_name: pp_name_t) (ty: term) (q: aqualv) : binder
let mk_binder (pp_name: pp_name_t) (ty: term) (q: aqualv) : binder = | false | null | false | pack_binder ({ ppname = pp_name; qual = q; attrs = []; sort = ty }) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Typing.pp_name_t",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Data.aqualv",
"FStar.Reflection.V2.Builtins.pack_binder",
"FStar.Reflection.V2.Data.Mkbinder_view",
"Prims.Nil",
"FStar.Reflection.Types.binder"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_binder (pp_name: pp_name_t) (ty: term) (q: aqualv) : binder | [] | FStar.Reflection.Typing.mk_binder | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
pp_name: FStar.Reflection.Typing.pp_name_t ->
ty: FStar.Reflection.Types.term ->
q: FStar.Reflection.V2.Data.aqualv
-> FStar.Reflection.Types.binder | {
"end_col": 20,
"end_line": 143,
"start_col": 4,
"start_line": 139
} |
Prims.Tot | val make_namedv (n: nat) : namedv_view | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
} | val make_namedv (n: nat) : namedv_view
let make_namedv (n: nat) : namedv_view = | false | null | false | { ppname = pp_name_default; uniq = n; sort = sort_default } | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"Prims.nat",
"FStar.Reflection.V2.Data.Mknamedv_view",
"FStar.Reflection.Typing.sort_default",
"FStar.Reflection.Typing.pp_name_default",
"FStar.Reflection.V2.Data.namedv_view"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val make_namedv (n: nat) : namedv_view | [] | FStar.Reflection.Typing.make_namedv | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | n: Prims.nat -> FStar.Reflection.V2.Data.namedv_view | {
"end_col": 24,
"end_line": 275,
"start_col": 2,
"start_line": 273
} |
Prims.Tot | val bindings_ok_for_branch (g: env) (bs: list R.binding) (br: branch) : Type0 | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bindings_ok_for_branch (g:env) (bs : list R.binding) (br : branch) : Type0 =
bindings_ok_for_pat g bs (fst br) | val bindings_ok_for_branch (g: env) (bs: list R.binding) (br: branch) : Type0
let bindings_ok_for_branch (g: env) (bs: list R.binding) (br: branch) : Type0 = | false | null | false | bindings_ok_for_pat g bs (fst br) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.env",
"Prims.list",
"FStar.Reflection.V2.Data.binding",
"FStar.Reflection.V2.Data.branch",
"FStar.Reflection.Typing.bindings_ok_for_pat",
"FStar.Pervasives.Native.fst",
"FStar.Reflection.V2.Data.pattern",
"FStar.Reflection.Types.term"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"]
let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f)
let rec __close_term_vs (i:nat) (vs : list var) (t : term) : Tot term (decreases vs) =
match vs with
| [] -> t
| v::vs ->
subst_term (__close_term_vs (i+1) vs t) [ND v i]
let close_term_vs (vs : list var) (t : term) : term =
__close_term_vs 0 vs t
let close_term_bs (bs : list binding) (t : term) : term =
close_term_vs (List.Tot.map fst bs) t
let bindings_to_refl_bindings (bs : list binding) : list R.binding =
L.map (fun (v, ty) -> {uniq=v; sort=ty; ppname = pp_name_default}) bs
let refl_bindings_to_bindings (bs : list R.binding) : list binding =
L.map (fun b -> b.uniq, b.sort) bs
[@@ no_auto_projectors]
noeq
type non_informative : env -> term -> Type0 =
| Non_informative_type:
g:env ->
u:universe ->
non_informative g (pack_ln (Tv_Type u))
| Non_informative_fv:
g:env ->
x:fv{is_non_informative_fv x} ->
non_informative g (pack_ln (Tv_FVar x))
| Non_informative_uinst:
g:env ->
x:fv{is_non_informative_fv x} ->
us:list universe ->
non_informative g (pack_ln (Tv_UInst x us))
| Non_informative_app:
g:env ->
t:term ->
arg:argv ->
non_informative g t ->
non_informative g (pack_ln (Tv_App t arg))
| Non_informative_total_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g t1 ->
non_informative g (mk_arrow_ct t0 q (T.E_Total, t1))
| Non_informative_ghost_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g (mk_arrow_ct t0 q (T.E_Ghost, t1))
| Non_informative_token:
g:env ->
t:typ ->
squash (T.non_informative_token g t) ->
non_informative g t
val bindings_ok_for_pat : env -> list R.binding -> pattern -> Type0
val bindings_ok_pat_constant :
g:env -> c:R.vconst -> Lemma (bindings_ok_for_pat g [] (Pat_Constant c)) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bindings_ok_for_branch (g: env) (bs: list R.binding) (br: branch) : Type0 | [] | FStar.Reflection.Typing.bindings_ok_for_branch | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
g: FStar.Reflection.Types.env ->
bs: Prims.list FStar.Reflection.V2.Data.binding ->
br: FStar.Reflection.V2.Data.branch
-> Type0 | {
"end_col": 35,
"end_line": 1109,
"start_col": 2,
"start_line": 1109
} |
Prims.Tot | val extend_env (e: env) (x: var) (ty: term) : env | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
}) | val extend_env (e: env) (x: var) (ty: term) : env
let extend_env (e: env) (x: var) (ty: term) : env = | false | null | false | R.push_binding e ({ ppname = seal_pp_name "x"; uniq = x; sort = ty }) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.env",
"FStar.Reflection.V2.Data.var",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Derived.push_binding",
"FStar.Reflection.V2.Data.Mkbinding",
"FStar.Reflection.Typing.seal_pp_name"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty} | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val extend_env (e: env) (x: var) (ty: term) : env | [] | FStar.Reflection.Typing.extend_env | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | e: FStar.Reflection.Types.env -> x: FStar.Reflection.V2.Data.var -> ty: FStar.Reflection.Types.term
-> FStar.Reflection.Types.env | {
"end_col": 4,
"end_line": 157,
"start_col": 2,
"start_line": 153
} |
Prims.Tot | val binding_to_namedv (b: R.binding) : Tot namedv | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let binding_to_namedv (b:R.binding) : Tot namedv =
pack_namedv {
RD.uniq = b.uniq;
RD.sort = seal b.sort;
RD.ppname = b.ppname;
} | val binding_to_namedv (b: R.binding) : Tot namedv
let binding_to_namedv (b: R.binding) : Tot namedv = | false | null | false | pack_namedv ({ RD.uniq = b.uniq; RD.sort = seal b.sort; RD.ppname = b.ppname }) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.V2.Data.binding",
"FStar.Reflection.V2.Builtins.pack_namedv",
"FStar.Reflection.V2.Data.Mknamedv_view",
"FStar.Reflection.V2.Data.__proj__Mkbinding__item__uniq",
"FStar.Sealed.seal",
"FStar.Reflection.Types.typ",
"FStar.Reflection.V2.Data.__proj__Mkbinding__item__sort",
"FStar.Reflection.V2.Data.__proj__Mkbinding__item__ppname",
"FStar.Reflection.Types.namedv"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"]
let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f)
let rec __close_term_vs (i:nat) (vs : list var) (t : term) : Tot term (decreases vs) =
match vs with
| [] -> t
| v::vs ->
subst_term (__close_term_vs (i+1) vs t) [ND v i]
let close_term_vs (vs : list var) (t : term) : term =
__close_term_vs 0 vs t
let close_term_bs (bs : list binding) (t : term) : term =
close_term_vs (List.Tot.map fst bs) t
let bindings_to_refl_bindings (bs : list binding) : list R.binding =
L.map (fun (v, ty) -> {uniq=v; sort=ty; ppname = pp_name_default}) bs
let refl_bindings_to_bindings (bs : list R.binding) : list binding =
L.map (fun b -> b.uniq, b.sort) bs
[@@ no_auto_projectors]
noeq
type non_informative : env -> term -> Type0 =
| Non_informative_type:
g:env ->
u:universe ->
non_informative g (pack_ln (Tv_Type u))
| Non_informative_fv:
g:env ->
x:fv{is_non_informative_fv x} ->
non_informative g (pack_ln (Tv_FVar x))
| Non_informative_uinst:
g:env ->
x:fv{is_non_informative_fv x} ->
us:list universe ->
non_informative g (pack_ln (Tv_UInst x us))
| Non_informative_app:
g:env ->
t:term ->
arg:argv ->
non_informative g t ->
non_informative g (pack_ln (Tv_App t arg))
| Non_informative_total_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g t1 ->
non_informative g (mk_arrow_ct t0 q (T.E_Total, t1))
| Non_informative_ghost_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g (mk_arrow_ct t0 q (T.E_Ghost, t1))
| Non_informative_token:
g:env ->
t:typ ->
squash (T.non_informative_token g t) ->
non_informative g t
val bindings_ok_for_pat : env -> list R.binding -> pattern -> Type0
val bindings_ok_pat_constant :
g:env -> c:R.vconst -> Lemma (bindings_ok_for_pat g [] (Pat_Constant c))
let bindings_ok_for_branch (g:env) (bs : list R.binding) (br : branch) : Type0 =
bindings_ok_for_pat g bs (fst br)
let bindings_ok_for_branch_N (g:env) (bss : list (list R.binding)) (brs : list branch) =
zip2prop (bindings_ok_for_branch g) bss brs | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val binding_to_namedv (b: R.binding) : Tot namedv | [] | FStar.Reflection.Typing.binding_to_namedv | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Reflection.V2.Data.binding -> FStar.Reflection.Types.namedv | {
"end_col": 3,
"end_line": 1119,
"start_col": 2,
"start_line": 1115
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bindings_ok_for_branch_N (g:env) (bss : list (list R.binding)) (brs : list branch) =
zip2prop (bindings_ok_for_branch g) bss brs | let bindings_ok_for_branch_N (g: env) (bss: list (list R.binding)) (brs: list branch) = | false | null | false | zip2prop (bindings_ok_for_branch g) bss brs | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.env",
"Prims.list",
"FStar.Reflection.V2.Data.binding",
"FStar.Reflection.V2.Data.branch",
"FStar.Reflection.Typing.zip2prop",
"FStar.Reflection.Typing.bindings_ok_for_branch"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"]
let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f)
let rec __close_term_vs (i:nat) (vs : list var) (t : term) : Tot term (decreases vs) =
match vs with
| [] -> t
| v::vs ->
subst_term (__close_term_vs (i+1) vs t) [ND v i]
let close_term_vs (vs : list var) (t : term) : term =
__close_term_vs 0 vs t
let close_term_bs (bs : list binding) (t : term) : term =
close_term_vs (List.Tot.map fst bs) t
let bindings_to_refl_bindings (bs : list binding) : list R.binding =
L.map (fun (v, ty) -> {uniq=v; sort=ty; ppname = pp_name_default}) bs
let refl_bindings_to_bindings (bs : list R.binding) : list binding =
L.map (fun b -> b.uniq, b.sort) bs
[@@ no_auto_projectors]
noeq
type non_informative : env -> term -> Type0 =
| Non_informative_type:
g:env ->
u:universe ->
non_informative g (pack_ln (Tv_Type u))
| Non_informative_fv:
g:env ->
x:fv{is_non_informative_fv x} ->
non_informative g (pack_ln (Tv_FVar x))
| Non_informative_uinst:
g:env ->
x:fv{is_non_informative_fv x} ->
us:list universe ->
non_informative g (pack_ln (Tv_UInst x us))
| Non_informative_app:
g:env ->
t:term ->
arg:argv ->
non_informative g t ->
non_informative g (pack_ln (Tv_App t arg))
| Non_informative_total_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g t1 ->
non_informative g (mk_arrow_ct t0 q (T.E_Total, t1))
| Non_informative_ghost_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g (mk_arrow_ct t0 q (T.E_Ghost, t1))
| Non_informative_token:
g:env ->
t:typ ->
squash (T.non_informative_token g t) ->
non_informative g t
val bindings_ok_for_pat : env -> list R.binding -> pattern -> Type0
val bindings_ok_pat_constant :
g:env -> c:R.vconst -> Lemma (bindings_ok_for_pat g [] (Pat_Constant c))
let bindings_ok_for_branch (g:env) (bs : list R.binding) (br : branch) : Type0 =
bindings_ok_for_pat g bs (fst br) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bindings_ok_for_branch_N : g: FStar.Reflection.Types.env ->
bss: Prims.list (Prims.list FStar.Reflection.V2.Data.binding) ->
brs: Prims.list FStar.Reflection.V2.Data.branch
-> Type0 | [] | FStar.Reflection.Typing.bindings_ok_for_branch_N | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
g: FStar.Reflection.Types.env ->
bss: Prims.list (Prims.list FStar.Reflection.V2.Data.binding) ->
brs: Prims.list FStar.Reflection.V2.Data.branch
-> Type0 | {
"end_col": 45,
"end_line": 1112,
"start_col": 2,
"start_line": 1112
} |
|
Prims.Tot | val make_bv_with_name (s: pp_name_t) (n: nat) : bv_view | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
} | val make_bv_with_name (s: pp_name_t) (n: nat) : bv_view
let make_bv_with_name (s: pp_name_t) (n: nat) : bv_view = | false | null | false | { ppname = s; index = n; sort = sort_default } | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Typing.pp_name_t",
"Prims.nat",
"FStar.Reflection.V2.Data.Mkbv_view",
"FStar.Reflection.Typing.sort_default",
"FStar.Reflection.V2.Data.bv_view"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
} | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val make_bv_with_name (s: pp_name_t) (n: nat) : bv_view | [] | FStar.Reflection.Typing.make_bv_with_name | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: FStar.Reflection.Typing.pp_name_t -> n: Prims.nat -> FStar.Reflection.V2.Data.bv_view | {
"end_col": 24,
"end_line": 266,
"start_col": 2,
"start_line": 264
} |
Prims.Tot | val subst_db (bv: bv) (s: subst) : term | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv) | val subst_db (bv: bv) (s: subst) : term
let subst_db (bv: bv) (s: subst) : term = | false | null | false | match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
let v:namedv =
pack_namedv ({ sort = (inspect_bv bv).sort; ppname = (inspect_bv bv).ppname; uniq = k })
in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.bv",
"FStar.Reflection.Typing.subst",
"FStar.Reflection.Typing.find_matching_subst_elt_bv",
"Prims.nat",
"FStar.Reflection.Types.term",
"FStar.Reflection.Typing.maybe_uniq_of_term",
"FStar.Reflection.V2.Data.var",
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_Var",
"FStar.Reflection.Types.namedv",
"FStar.Reflection.V2.Builtins.pack_namedv",
"FStar.Reflection.V2.Data.Mknamedv_view",
"FStar.Reflection.V2.Data.__proj__Mkbv_view__item__sort",
"FStar.Reflection.V2.Builtins.inspect_bv",
"FStar.Reflection.V2.Data.__proj__Mkbv_view__item__ppname",
"FStar.Pervasives.Native.option",
"FStar.Reflection.Typing.subst_elt",
"FStar.Reflection.V2.Data.Tv_BVar"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val subst_db (bv: bv) (s: subst) : term | [] | FStar.Reflection.Typing.subst_db | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bv: FStar.Reflection.Types.bv -> s: FStar.Reflection.Typing.subst -> FStar.Reflection.Types.term | {
"end_col": 29,
"end_line": 230,
"start_col": 2,
"start_line": 218
} |
Prims.Tot | val find_matching_subst_elt_bv (s: subst) (bv: bv) : option subst_elt | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv | val find_matching_subst_elt_bv (s: subst) (bv: bv) : option subst_elt
let rec find_matching_subst_elt_bv (s: subst) (bv: bv) : option subst_elt = | false | null | false | match s with
| [] -> None
| DT j t :: ss -> if j = bv_index bv then Some (DT j t) else find_matching_subst_elt_bv ss bv
| _ :: ss -> find_matching_subst_elt_bv ss bv | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Typing.subst",
"FStar.Reflection.Types.bv",
"FStar.Pervasives.Native.None",
"FStar.Reflection.Typing.subst_elt",
"Prims.nat",
"FStar.Reflection.Types.term",
"Prims.list",
"Prims.op_Equality",
"FStar.Reflection.Typing.bv_index",
"FStar.Pervasives.Native.Some",
"FStar.Reflection.Typing.DT",
"Prims.bool",
"FStar.Reflection.Typing.find_matching_subst_elt_bv",
"FStar.Pervasives.Native.option"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val find_matching_subst_elt_bv (s: subst) (bv: bv) : option subst_elt | [
"recursion"
] | FStar.Reflection.Typing.find_matching_subst_elt_bv | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: FStar.Reflection.Typing.subst -> bv: FStar.Reflection.Types.bv
-> FStar.Pervasives.Native.option FStar.Reflection.Typing.subst_elt | {
"end_col": 45,
"end_line": 215,
"start_col": 2,
"start_line": 209
} |
Prims.Tot | val find_matching_subst_elt_var (s: subst) (v: namedv) : option subst_elt | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v | val find_matching_subst_elt_var (s: subst) (v: namedv) : option subst_elt
let rec find_matching_subst_elt_var (s: subst) (v: namedv) : option subst_elt = | false | null | false | match s with
| [] -> None
| NT y _ :: rest
| ND y _ :: rest -> if y = namedv_uniq v then Some (L.hd s) else find_matching_subst_elt_var rest v
| _ :: rest -> find_matching_subst_elt_var rest v | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Typing.subst",
"FStar.Reflection.Types.namedv",
"FStar.Pervasives.Native.None",
"FStar.Reflection.Typing.subst_elt",
"FStar.Reflection.V2.Data.var",
"FStar.Reflection.Types.term",
"Prims.list",
"Prims.op_Equality",
"FStar.Reflection.Typing.namedv_uniq",
"FStar.Pervasives.Native.Some",
"FStar.List.Tot.Base.hd",
"Prims.bool",
"FStar.Reflection.Typing.find_matching_subst_elt_var",
"FStar.Pervasives.Native.option",
"Prims.nat"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val find_matching_subst_elt_var (s: subst) (v: namedv) : option subst_elt | [
"recursion"
] | FStar.Reflection.Typing.find_matching_subst_elt_var | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: FStar.Reflection.Typing.subst -> v: FStar.Reflection.Types.namedv
-> FStar.Pervasives.Native.option FStar.Reflection.Typing.subst_elt | {
"end_col": 49,
"end_line": 240,
"start_col": 2,
"start_line": 233
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let blob = string & R.term | let blob = | false | null | false | string & R.term | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"Prims.string",
"FStar.Reflection.Types.term"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"]
let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f)
let rec __close_term_vs (i:nat) (vs : list var) (t : term) : Tot term (decreases vs) =
match vs with
| [] -> t
| v::vs ->
subst_term (__close_term_vs (i+1) vs t) [ND v i]
let close_term_vs (vs : list var) (t : term) : term =
__close_term_vs 0 vs t
let close_term_bs (bs : list binding) (t : term) : term =
close_term_vs (List.Tot.map fst bs) t
let bindings_to_refl_bindings (bs : list binding) : list R.binding =
L.map (fun (v, ty) -> {uniq=v; sort=ty; ppname = pp_name_default}) bs
let refl_bindings_to_bindings (bs : list R.binding) : list binding =
L.map (fun b -> b.uniq, b.sort) bs
[@@ no_auto_projectors]
noeq
type non_informative : env -> term -> Type0 =
| Non_informative_type:
g:env ->
u:universe ->
non_informative g (pack_ln (Tv_Type u))
| Non_informative_fv:
g:env ->
x:fv{is_non_informative_fv x} ->
non_informative g (pack_ln (Tv_FVar x))
| Non_informative_uinst:
g:env ->
x:fv{is_non_informative_fv x} ->
us:list universe ->
non_informative g (pack_ln (Tv_UInst x us))
| Non_informative_app:
g:env ->
t:term ->
arg:argv ->
non_informative g t ->
non_informative g (pack_ln (Tv_App t arg))
| Non_informative_total_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g t1 ->
non_informative g (mk_arrow_ct t0 q (T.E_Total, t1))
| Non_informative_ghost_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g (mk_arrow_ct t0 q (T.E_Ghost, t1))
| Non_informative_token:
g:env ->
t:typ ->
squash (T.non_informative_token g t) ->
non_informative g t
val bindings_ok_for_pat : env -> list R.binding -> pattern -> Type0
val bindings_ok_pat_constant :
g:env -> c:R.vconst -> Lemma (bindings_ok_for_pat g [] (Pat_Constant c))
let bindings_ok_for_branch (g:env) (bs : list R.binding) (br : branch) : Type0 =
bindings_ok_for_pat g bs (fst br)
let bindings_ok_for_branch_N (g:env) (bss : list (list R.binding)) (brs : list branch) =
zip2prop (bindings_ok_for_branch g) bss brs
let binding_to_namedv (b:R.binding) : Tot namedv =
pack_namedv {
RD.uniq = b.uniq;
RD.sort = seal b.sort;
RD.ppname = b.ppname;
}
(* Elaborates the p pattern into a term, using the bs bindings for the
pattern variables. The resulting term is properly scoped only on an
environment which contains all of bs. See for instance the branch_typing
judg. Returns an option, since this can fail if e.g. there are not
enough bindings, and returns the list of unused binders as well, which
should be empty if the list of binding was indeed ok. *)
let rec elaborate_pat (p : pattern) (bs : list R.binding) : Tot (option (term & list R.binding)) (decreases p) =
match p, bs with
| Pat_Constant c, _ -> Some (pack_ln (Tv_Const c), bs)
| Pat_Cons fv univs subpats, bs ->
let head = pack_ln (Tv_FVar fv) in
fold_left_dec
(Some (head, bs))
subpats
(fun st pi ->
let (p,i) = pi in
match st with | None -> None | Some (head, bs) ->
match elaborate_pat p bs with | None -> None | Some (t, bs') -> Some (pack_ln (Tv_App head (t, (if i then Q_Implicit else Q_Explicit))), bs'))
| Pat_Var _ _, b::bs ->
Some (pack_ln (Tv_Var (binding_to_namedv b)), bs)
| Pat_Dot_Term (Some t), _ -> Some (t, bs)
| Pat_Dot_Term None, _ -> None
| _ -> None
[@@ no_auto_projectors]
noeq
type typing : env -> term -> comp_typ -> Type0 =
| T_Token :
g:env ->
e:term ->
c:comp_typ ->
squash (T.typing_token g e c) ->
typing g e c
| T_Var :
g:env ->
x:namedv { Some? (lookup_bvar g (namedv_uniq x)) } ->
typing g (pack_ln (Tv_Var x)) (T.E_Total, Some?.v (lookup_bvar g (namedv_uniq x)))
| T_FVar :
g:env ->
x:fv { Some? (lookup_fvar g x) } ->
typing g (pack_ln (Tv_FVar x)) (T.E_Total, Some?.v (lookup_fvar g x))
| T_UInst :
g:env ->
x:fv ->
us:list universe { Some? (lookup_fvar_uinst g x us) } ->
typing g (pack_ln (Tv_UInst x us)) (T.E_Total, Some?.v (lookup_fvar_uinst g x us))
| T_Const:
g:env ->
v:vconst ->
t:term ->
constant_typing v t ->
typing g (constant_as_term v) (T.E_Total, t)
| T_Abs :
g:env ->
x:var { None? (lookup_bvar g x) } ->
ty:term ->
body:term { ~(x `Set.mem` freevars body) } ->
body_c:comp_typ ->
u:universe ->
pp_name:pp_name_t ->
q:aqualv ->
ty_eff:T.tot_or_ghost ->
typing g ty (ty_eff, tm_type u) ->
typing (extend_env g x ty) (open_term body x) body_c ->
typing g (pack_ln (Tv_Abs (mk_binder pp_name ty q) body))
(T.E_Total,
pack_ln (Tv_Arrow (mk_binder pp_name ty q)
(mk_comp (close_comp_typ body_c x))))
| T_App :
g:env ->
e1:term ->
e2:term ->
x:binder ->
t:term ->
eff:T.tot_or_ghost ->
typing g e1 (eff, pack_ln (Tv_Arrow x (mk_comp (eff, t)))) ->
typing g e2 (eff, binder_sort x) ->
typing g (pack_ln (Tv_App e1 (e2, binder_qual x)))
(eff, open_with t e2)
| T_Let:
g:env ->
x:var { None? (lookup_bvar g x) } ->
e1:term ->
t1:typ ->
e2:term ->
t2:typ ->
eff:T.tot_or_ghost ->
pp_name:pp_name_t ->
typing g e1 (eff, t1) ->
typing (extend_env g x t1) (open_term e2 x) (eff, t2) ->
typing g (mk_let pp_name e1 t1 e2) (eff, open_with (close_term t2 x) e1)
| T_Arrow:
g:env ->
x:var { None? (lookup_bvar g x) } ->
t1:term ->
t2:term { ~(x `Set.mem` freevars t2) } ->
u1:universe ->
u2:universe ->
pp_name:pp_name_t ->
q:aqualv ->
eff:T.tot_or_ghost ->
t1_eff:T.tot_or_ghost ->
t2_eff:T.tot_or_ghost ->
typing g t1 (t1_eff, tm_type u1) ->
typing (extend_env g x t1) (open_term t2 x) (t2_eff, tm_type u2) ->
typing g (pack_ln (Tv_Arrow (mk_binder pp_name t1 q) (mk_comp (eff, t2))))
(T.E_Total, tm_type (u_max u1 u2))
| T_Refine:
g:env ->
x:var { None? (lookup_bvar g x) } ->
t:term ->
e:term { ~(x `Set.mem` freevars e) } ->
u1:universe ->
u2:universe ->
t_eff:T.tot_or_ghost ->
e_eff:T.tot_or_ghost ->
typing g t (t_eff, tm_type u1) ->
typing (extend_env g x t) (open_term e x) (e_eff, tm_type u2) ->
typing g (pack_ln (Tv_Refine (mk_simple_binder pp_name_default t) e)) (T.E_Total, tm_type u1)
| T_PropIrrelevance:
g:env ->
e:term ->
t:term ->
e_eff:T.tot_or_ghost ->
t_eff:T.tot_or_ghost ->
typing g e (e_eff, t) ->
typing g t (t_eff, tm_prop) ->
typing g (`()) (T.E_Total, t)
| T_Sub:
g:env ->
e:term ->
c:comp_typ ->
c':comp_typ ->
typing g e c ->
sub_comp g c c' ->
typing g e c'
| T_If:
g:env ->
scrutinee:term ->
then_:term ->
else_:term ->
ty:term ->
u_ty:universe ->
hyp:var { None? (lookup_bvar g hyp) /\ ~(hyp `Set.mem` (freevars then_ `Set.union` freevars else_)) } ->
eff:T.tot_or_ghost ->
ty_eff:T.tot_or_ghost ->
typing g scrutinee (eff, bool_ty) ->
typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee true_bool)) then_ (eff, ty) ->
typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee false_bool)) else_ (eff, ty) ->
typing g ty (ty_eff, tm_type u_ty) -> //typedness of ty cannot rely on hyp
typing g (mk_if scrutinee then_ else_) (eff, ty)
| T_Match:
g:env ->
sc_u : universe ->
sc_ty : typ ->
sc : term ->
ty_eff:T.tot_or_ghost ->
typing g sc_ty (ty_eff, tm_type sc_u) ->
eff:T.tot_or_ghost ->
typing g sc (eff, sc_ty) ->
branches:list branch ->
ty:comp_typ ->
bnds:list (list R.binding) ->
complet : match_is_complete g sc sc_ty (List.Tot.map fst branches) bnds -> // complete patterns
branches_typing g sc_u sc_ty sc ty branches bnds -> // each branch has proper type
typing g (pack_ln (Tv_Match sc None branches)) ty
and related : env -> term -> relation -> term -> Type0 =
| Rel_refl:
g:env ->
t:term ->
rel:relation ->
related g t rel t
| Rel_sym:
g:env ->
t0:term ->
t1:term ->
related g t0 R_Eq t1 ->
related g t1 R_Eq t0
| Rel_trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
rel:relation ->
related g t0 rel t1 ->
related g t1 rel t2 ->
related g t0 rel t2
| Rel_univ:
g:env ->
u:universe ->
v:universe ->
univ_eq u v ->
related g (tm_type u) R_Eq (tm_type v)
| Rel_beta:
g:env ->
t:typ ->
q:aqualv ->
e:term { ln' e 0 } ->
arg:term { ln arg } ->
related g (R.pack_ln (R.Tv_App (mk_abs t q e) (arg, q)))
R_Eq
(subst_term e [ DT 0 arg ])
| Rel_eq_token:
g:env ->
t0:term ->
t1:term ->
squash (T.equiv_token g t0 t1) ->
related g t0 R_Eq t1
| Rel_subtyping_token:
g:env ->
t0:term ->
t1:term ->
squash (T.subtyping_token g t0 t1) ->
related g t0 R_Sub t1
| Rel_equiv:
g:env ->
t0:term ->
t1:term ->
rel:relation ->
related g t0 R_Eq t1 ->
related g t0 rel t1
| Rel_arrow:
g:env ->
t1:term ->
t2:term ->
q:aqualv ->
c1:comp_typ ->
c2:comp_typ ->
rel:relation ->
x:var{
None? (lookup_bvar g x) /\
~ (x `Set.mem` (freevars_comp_typ c1 `Set.union` freevars_comp_typ c2))
} ->
related g t2 rel t1 ->
related_comp (extend_env g x t2)
(open_comp_typ c1 x)
rel
(open_comp_typ c2 x) ->
related g (mk_arrow_ct t1 q c1) rel (mk_arrow_ct t2 q c2)
| Rel_abs:
g:env ->
t1:term ->
t2:term ->
q:aqualv ->
e1:term ->
e2:term ->
x:var{
None? (lookup_bvar g x) /\ ~ (x `Set.mem` (freevars e1 `Set.union` freevars e2))
} ->
related g t1 R_Eq t2 ->
related (extend_env g x t1)
(subst_term e1 (open_with_var x 0))
R_Eq
(subst_term e2 (open_with_var x 0)) ->
related g (mk_abs t1 q e1) R_Eq (mk_abs t2 q e2)
| Rel_ctxt:
g:env ->
t0:term ->
t1:term ->
ctxt:term_ctxt ->
related g t0 R_Eq t1 ->
related g (apply_term_ctxt ctxt t0) R_Eq (apply_term_ctxt ctxt t1)
and related_comp : env -> comp_typ -> relation -> comp_typ -> Type0 =
| Relc_typ:
g:env ->
t0:term ->
t1:term ->
eff:T.tot_or_ghost ->
rel:relation ->
related g t0 rel t1 ->
related_comp g (eff, t0) rel (eff, t1)
| Relc_total_ghost:
g:env ->
t:term ->
related_comp g (T.E_Total, t) R_Sub (T.E_Ghost, t)
| Relc_ghost_total:
g:env ->
t:term ->
non_informative g t ->
related_comp g (T.E_Ghost, t) R_Sub (T.E_Total, t)
and branches_typing (g:env) (sc_u:universe) (sc_ty:typ) (sc:term) (rty:comp_typ)
: (brs:list branch) -> (bnds : list (list R.binding)) -> Type0
=
(* This judgement only enforces that branch_typing holds for every
element of brs and its respective bnds (which must have the same
length). *)
| BT_Nil :
branches_typing g sc_u sc_ty sc rty [] []
| BT_S :
br : branch ->
bnds : list R.binding ->
pf : branch_typing g sc_u sc_ty sc rty br bnds ->
rest_br : list branch ->
rest_bnds : list (list R.binding) ->
rest : branches_typing g sc_u sc_ty sc rty rest_br rest_bnds ->
branches_typing g sc_u sc_ty sc rty (br :: rest_br) (bnds :: rest_bnds)
and branch_typing (g:env) (sc_u:universe) (sc_ty:typ) (sc:term) (rty:comp_typ)
: (br : branch) -> (bnds : list R.binding) -> Type0
=
| BO :
pat : pattern ->
bnds : list R.binding{bindings_ok_for_pat g bnds pat} ->
hyp_var:var{None? (lookup_bvar (extend_env_l g (refl_bindings_to_bindings bnds)) hyp_var)} ->
body:term ->
_ : squash (Some? (elaborate_pat pat bnds)) ->
typing (extend_env
(extend_env_l g (refl_bindings_to_bindings bnds))
hyp_var (eq2 sc_u sc_ty sc (fst (Some?.v (elaborate_pat pat bnds))))
)
body rty ->
branch_typing g sc_u sc_ty sc rty
(pat, close_term_bs (refl_bindings_to_bindings bnds) body)
bnds
and match_is_complete : env -> term -> typ -> list pattern -> list (list R.binding) -> Type0 =
| MC_Tok :
env:_ ->
sc:_ ->
ty:_ ->
pats:_ ->
bnds:_ ->
squash (T.match_complete_token env sc ty pats bnds) -> match_is_complete env sc ty pats bnds
and sub_typing (g:env) (t1 t2:term) = related g t1 R_Sub t2
and sub_comp (g:env) (c1 c2:comp_typ) = related_comp g c1 R_Sub c2
and equiv (g:env) (t1 t2:term) = related g t1 R_Eq t2
type tot_typing (g:env) (e:term) (t:term) = typing g e (T.E_Total, t)
type ghost_typing (g:env) (e:term) (t:term) = typing g e (T.E_Ghost, t)
val subtyping_token_renaming (g:env)
(bs0:bindings)
(bs1:bindings)
(x:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) x) })
(y:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) y) })
(t:term)
(t0 t1:term)
(d:T.subtyping_token (extend_env_l g (bs1@(x,t)::bs0)) t0 t1)
: T.subtyping_token (extend_env_l g (rename_bindings bs1 x y@(y,t)::bs0))
(rename t0 x y)
(rename t1 x y)
val subtyping_token_weakening (g:env)
(bs0:bindings)
(bs1:bindings)
(x:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) x) })
(t:term)
(t0 t1:term)
(d:T.subtyping_token (extend_env_l g (bs1@bs0)) t0 t1)
: T.subtyping_token (extend_env_l g (bs1@(x,t)::bs0)) t0 t1
let simplify_umax (#g:R.env) (#t:R.term) (#u:R.universe)
(d:typing g t (T.E_Total, tm_type (u_max u u)))
: typing g t (T.E_Total, tm_type u)
= let ue
: univ_eq (u_max u u) u
= UN_MaxLeq u u (UNLEQ_Refl u)
in
let du : related g (tm_type (u_max u u)) R_Eq (tm_type u)
= Rel_univ g (u_max u u) u ue in
let du : related g (tm_type (u_max u u)) R_Sub (tm_type u)
= Rel_equiv _ _ _ _ du in
T_Sub _ _ _ _ d (Relc_typ _ _ _ T.E_Total _ du)
val well_typed_terms_are_ln (g:R.env) (e:R.term) (c:comp_typ) (_:typing g e c)
: Lemma (ensures ln e /\ ln (snd c))
val type_correctness (g:R.env) (e:R.term) (c:comp_typ) (_:typing g e c)
: GTot (u:R.universe & typing g (snd c) (T.E_Total, tm_type u))
val binder_offset_pattern_invariant (p:pattern) (ss:subst)
: Lemma (binder_offset_pattern p == binder_offset_pattern (subst_pattern p ss))
val binder_offset_patterns_invariant (p:list (pattern & bool)) (ss:subst)
: Lemma (binder_offset_patterns p == binder_offset_patterns (subst_patterns p ss))
val open_close_inverse' (i:nat) (t:term { ln' t (i - 1) }) (x:var)
: Lemma
(ensures subst_term
(subst_term t [ ND x i ])
(open_with_var x i)
== t)
val open_close_inverse'_binder (i:nat) (b:binder { ln'_binder b (i - 1) }) (x:var)
: Lemma (ensures subst_binder
(subst_binder b [ ND x i ])
(open_with_var x i)
== b)
val open_close_inverse'_terms (i:nat) (ts:list term { ln'_terms ts (i - 1) }) (x:var)
: Lemma (ensures subst_terms
(subst_terms ts [ ND x i ])
(open_with_var x i)
== ts)
val open_close_inverse'_comp (i:nat) (c:comp { ln'_comp c (i - 1) }) (x:var)
: Lemma
(ensures subst_comp
(subst_comp c [ ND x i ])
(open_with_var x i)
== c)
val open_close_inverse'_args (i:nat)
(ts:list argv { ln'_args ts (i - 1) })
(x:var)
: Lemma
(ensures subst_args
(subst_args ts [ ND x i ])
(open_with_var x i)
== ts)
val open_close_inverse'_patterns (i:nat)
(ps:list (pattern & bool) { ln'_patterns ps (i - 1) })
(x:var)
: Lemma
(ensures subst_patterns
(subst_patterns ps [ ND x i ])
(open_with_var x i)
== ps)
val open_close_inverse'_pattern (i:nat) (p:pattern{ln'_pattern p (i - 1)}) (x:var)
: Lemma
(ensures subst_pattern
(subst_pattern p [ ND x i ])
(open_with_var x i)
== p)
val open_close_inverse'_branch (i:nat) (br:branch{ln'_branch br (i - 1)}) (x:var)
: Lemma
(ensures subst_branch
(subst_branch br [ ND x i ])
(open_with_var x i)
== br)
val open_close_inverse'_branches (i:nat)
(brs:list branch { ln'_branches brs (i - 1) })
(x:var)
: Lemma
(ensures subst_branches
(subst_branches brs [ ND x i ])
(open_with_var x i)
== brs)
val open_close_inverse'_match_returns (i:nat)
(m:match_returns_ascription { ln'_match_returns m (i - 1) })
(x:var)
: Lemma
(ensures subst_match_returns
(subst_match_returns m [ ND x i ])
(open_with_var x i)
== m)
val open_close_inverse (e:R.term { ln e }) (x:var)
: Lemma (open_term (close_term e x) x == e)
val close_open_inverse' (i:nat)
(t:term)
(x:var { ~(x `Set.mem` freevars t) })
: Lemma
(ensures subst_term
(subst_term t (open_with_var x i))
[ ND x i ]
== t)
val close_open_inverse'_comp (i:nat)
(c:comp)
(x:var{ ~(x `Set.mem` freevars_comp c) })
: Lemma
(ensures subst_comp
(subst_comp c (open_with_var x i))
[ ND x i ]
== c)
val close_open_inverse'_args (i:nat) (args:list argv) (x:var{ ~(x `Set.mem` freevars_args args) })
: Lemma
(ensures subst_args
(subst_args args (open_with_var x i))
[ ND x i]
== args)
val close_open_inverse'_binder (i:nat) (b:binder) (x:var{ ~(x `Set.mem` freevars_binder b) })
: Lemma
(ensures subst_binder
(subst_binder b (open_with_var x i))
[ ND x i ]
== b)
val close_open_inverse'_terms (i:nat) (ts:list term) (x:var{ ~(x `Set.mem` freevars_terms ts) })
: Lemma
(ensures subst_terms
(subst_terms ts (open_with_var x i))
[ ND x i ]
== ts)
val close_open_inverse'_branches (i:nat) (brs:list branch)
(x:var{ ~(x `Set.mem` freevars_branches brs) })
: Lemma
(ensures subst_branches
(subst_branches brs (open_with_var x i))
[ ND x i ]
== brs)
val close_open_inverse'_branch (i:nat)
(br:branch)
(x:var{ ~(x `Set.mem` freevars_branch br) })
: Lemma
(ensures subst_branch
(subst_branch br (open_with_var x i))
[ ND x i ]
== br)
val close_open_inverse'_pattern (i:nat)
(p:pattern)
(x:var{ ~(x `Set.mem` freevars_pattern p) })
: Lemma
(ensures subst_pattern
(subst_pattern p (open_with_var x i))
[ ND x i ]
== p)
val close_open_inverse'_patterns (i:nat)
(ps:list (pattern & bool))
(x:var {~ (x `Set.mem` freevars_patterns ps) })
: Lemma
(ensures subst_patterns
(subst_patterns ps (open_with_var x i))
[ ND x i ]
== ps)
val close_open_inverse'_match_returns (i:nat) (m:match_returns_ascription)
(x:var{ ~(x `Set.mem` freevars_match_returns m) })
: Lemma
(ensures subst_match_returns
(subst_match_returns m (open_with_var x i))
[ ND x i ]
== m)
val close_open_inverse (e:R.term) (x:var {~ (x `Set.mem` freevars e) })
: Lemma (close_term (open_term e x) x == e)
//
// fst has corresponding lemmas for other syntax classes
//
val close_with_not_free_var (t:R.term) (x:var) (i:nat)
: Lemma
(requires ~ (Set.mem x (freevars t)))
(ensures subst_term t [ ND x i ] == t)
// this also requires x to be not in freevars e1 `Set.union` freevars e2
val equiv_arrow (#g:R.env) (#e1 #e2:R.term) (ty:R.typ) (q:R.aqualv)
(x:var { None? (lookup_bvar g x) })
(eq:equiv (extend_env g x ty)
(subst_term e1 (open_with_var x 0))
(subst_term e2 (open_with_var x 0)))
: equiv g (mk_arrow ty q e1)
(mk_arrow ty q e2)
// the proof for this requires e1 and e2 to be ln
val equiv_abs_close (#g:R.env) (#e1 #e2:R.term) (ty:R.typ) (q:R.aqualv)
(x:var{None? (lookup_bvar g x)})
(eq:equiv (extend_env g x ty) e1 e2)
: equiv g (mk_abs ty q (subst_term e1 [ ND x 0 ]))
(mk_abs ty q (subst_term e2 [ ND x 0 ]))
val open_with_gt_ln (e:term) (i:nat) (t:term) (j:nat)
: Lemma
(requires ln' e i /\ i < j)
(ensures subst_term e [ DT j t ] == e)
[SMTPat (ln' e i); SMTPat (subst_term e [ DT j t ])]
//
// Type of the top-level tactic that would splice-in the definitions
//
let fstar_env_fvs (g:R.env) =
lookup_fvar g unit_fv == Some (tm_type u_zero) /\
lookup_fvar g bool_fv == Some (tm_type u_zero) /\
lookup_fvar g b2t_fv == Some b2t_ty
type fstar_env = g:R.env{fstar_env_fvs g}
type fstar_top_env = g:fstar_env {
forall x. None? (lookup_bvar g x )
}
//
// This doesn't allow for universe polymorphic definitions
//
// May be we can change it to:
//
// g:fstar_top_env -> T.tac ((us, e, t):(univ_names & term & typ){typing (push g us) e t})
//
noeq
type sigelt_typing : env -> sigelt -> Type0 =
| ST_Let :
g : env ->
fv : R.fv ->
ty : R.typ ->
tm : R.term ->
squash (typing g tm (T.E_Total, ty)) ->
sigelt_typing g (pack_sigelt (Sg_Let false [pack_lb ({ lb_fv = fv; lb_us = []; lb_typ = ty; lb_def = tm })]))
| ST_Let_Opaque :
g : env ->
fv : R.fv ->
ty : R.typ ->
(* no tm: only a proof of existence *)
squash (exists (tm:R.term). typing g tm (T.E_Total, ty)) ->
sigelt_typing g (pack_sigelt (Sg_Let false [pack_lb ({ lb_fv = fv; lb_us = []; lb_typ = ty; lb_def = (`_) })]))
(**
* The type of the top-level tactic that would splice-in the definitions.
* It returns a list of well typed definitions, via the judgment above.
*
* Each definition can have a 'blob' attached with a given name.
* The blob can be used later, e.g., during extraction, and passed back to the
* extension to perform additional processing.
*)
(*
* It returns either:
* - Some tm, blob, typ, with a proof that `typing g tm typ`
* - None, blob, typ), with a proof that `exists tm. typing g tm typ`
* The blob itself is optional and can store some additional metadata that
* constructed by the tactic. If present, it will be stored in the
* sigmeta_extension_data field of the enclosing sigelt.
* | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val blob : Type0 | [] | FStar.Reflection.Typing.blob | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 26,
"end_line": 1793,
"start_col": 11,
"start_line": 1793
} |
|
Prims.Tot | val simplify_umax
(#g: R.env)
(#t: R.term)
(#u: R.universe)
(d: typing g t (T.E_Total, tm_type (u_max u u)))
: typing g t (T.E_Total, tm_type u) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let simplify_umax (#g:R.env) (#t:R.term) (#u:R.universe)
(d:typing g t (T.E_Total, tm_type (u_max u u)))
: typing g t (T.E_Total, tm_type u)
= let ue
: univ_eq (u_max u u) u
= UN_MaxLeq u u (UNLEQ_Refl u)
in
let du : related g (tm_type (u_max u u)) R_Eq (tm_type u)
= Rel_univ g (u_max u u) u ue in
let du : related g (tm_type (u_max u u)) R_Sub (tm_type u)
= Rel_equiv _ _ _ _ du in
T_Sub _ _ _ _ d (Relc_typ _ _ _ T.E_Total _ du) | val simplify_umax
(#g: R.env)
(#t: R.term)
(#u: R.universe)
(d: typing g t (T.E_Total, tm_type (u_max u u)))
: typing g t (T.E_Total, tm_type u)
let simplify_umax
(#g: R.env)
(#t: R.term)
(#u: R.universe)
(d: typing g t (T.E_Total, tm_type (u_max u u)))
: typing g t (T.E_Total, tm_type u) = | false | null | false | let ue:univ_eq (u_max u u) u = UN_MaxLeq u u (UNLEQ_Refl u) in
let du:related g (tm_type (u_max u u)) R_Eq (tm_type u) = Rel_univ g (u_max u u) u ue in
let du:related g (tm_type (u_max u u)) R_Sub (tm_type u) = Rel_equiv _ _ _ _ du in
T_Sub _ _ _ _ d (Relc_typ _ _ _ T.E_Total _ du) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.env",
"FStar.Reflection.Types.term",
"FStar.Reflection.Types.universe",
"FStar.Reflection.Typing.typing",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Stubs.TypeChecker.Core.tot_or_ghost",
"FStar.Reflection.Types.typ",
"FStar.Stubs.TypeChecker.Core.E_Total",
"FStar.Reflection.Typing.tm_type",
"FStar.Reflection.Typing.u_max",
"FStar.Reflection.Typing.T_Sub",
"FStar.Reflection.Typing.Relc_typ",
"FStar.Reflection.Typing.R_Sub",
"FStar.Reflection.Typing.related",
"FStar.Reflection.Typing.Rel_equiv",
"FStar.Reflection.Typing.R_Eq",
"FStar.Reflection.Typing.Rel_univ",
"FStar.Reflection.Typing.univ_eq",
"FStar.Reflection.Typing.UN_MaxLeq",
"FStar.Reflection.Typing.UNLEQ_Refl"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"]
let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f)
let rec __close_term_vs (i:nat) (vs : list var) (t : term) : Tot term (decreases vs) =
match vs with
| [] -> t
| v::vs ->
subst_term (__close_term_vs (i+1) vs t) [ND v i]
let close_term_vs (vs : list var) (t : term) : term =
__close_term_vs 0 vs t
let close_term_bs (bs : list binding) (t : term) : term =
close_term_vs (List.Tot.map fst bs) t
let bindings_to_refl_bindings (bs : list binding) : list R.binding =
L.map (fun (v, ty) -> {uniq=v; sort=ty; ppname = pp_name_default}) bs
let refl_bindings_to_bindings (bs : list R.binding) : list binding =
L.map (fun b -> b.uniq, b.sort) bs
[@@ no_auto_projectors]
noeq
type non_informative : env -> term -> Type0 =
| Non_informative_type:
g:env ->
u:universe ->
non_informative g (pack_ln (Tv_Type u))
| Non_informative_fv:
g:env ->
x:fv{is_non_informative_fv x} ->
non_informative g (pack_ln (Tv_FVar x))
| Non_informative_uinst:
g:env ->
x:fv{is_non_informative_fv x} ->
us:list universe ->
non_informative g (pack_ln (Tv_UInst x us))
| Non_informative_app:
g:env ->
t:term ->
arg:argv ->
non_informative g t ->
non_informative g (pack_ln (Tv_App t arg))
| Non_informative_total_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g t1 ->
non_informative g (mk_arrow_ct t0 q (T.E_Total, t1))
| Non_informative_ghost_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g (mk_arrow_ct t0 q (T.E_Ghost, t1))
| Non_informative_token:
g:env ->
t:typ ->
squash (T.non_informative_token g t) ->
non_informative g t
val bindings_ok_for_pat : env -> list R.binding -> pattern -> Type0
val bindings_ok_pat_constant :
g:env -> c:R.vconst -> Lemma (bindings_ok_for_pat g [] (Pat_Constant c))
let bindings_ok_for_branch (g:env) (bs : list R.binding) (br : branch) : Type0 =
bindings_ok_for_pat g bs (fst br)
let bindings_ok_for_branch_N (g:env) (bss : list (list R.binding)) (brs : list branch) =
zip2prop (bindings_ok_for_branch g) bss brs
let binding_to_namedv (b:R.binding) : Tot namedv =
pack_namedv {
RD.uniq = b.uniq;
RD.sort = seal b.sort;
RD.ppname = b.ppname;
}
(* Elaborates the p pattern into a term, using the bs bindings for the
pattern variables. The resulting term is properly scoped only on an
environment which contains all of bs. See for instance the branch_typing
judg. Returns an option, since this can fail if e.g. there are not
enough bindings, and returns the list of unused binders as well, which
should be empty if the list of binding was indeed ok. *)
let rec elaborate_pat (p : pattern) (bs : list R.binding) : Tot (option (term & list R.binding)) (decreases p) =
match p, bs with
| Pat_Constant c, _ -> Some (pack_ln (Tv_Const c), bs)
| Pat_Cons fv univs subpats, bs ->
let head = pack_ln (Tv_FVar fv) in
fold_left_dec
(Some (head, bs))
subpats
(fun st pi ->
let (p,i) = pi in
match st with | None -> None | Some (head, bs) ->
match elaborate_pat p bs with | None -> None | Some (t, bs') -> Some (pack_ln (Tv_App head (t, (if i then Q_Implicit else Q_Explicit))), bs'))
| Pat_Var _ _, b::bs ->
Some (pack_ln (Tv_Var (binding_to_namedv b)), bs)
| Pat_Dot_Term (Some t), _ -> Some (t, bs)
| Pat_Dot_Term None, _ -> None
| _ -> None
[@@ no_auto_projectors]
noeq
type typing : env -> term -> comp_typ -> Type0 =
| T_Token :
g:env ->
e:term ->
c:comp_typ ->
squash (T.typing_token g e c) ->
typing g e c
| T_Var :
g:env ->
x:namedv { Some? (lookup_bvar g (namedv_uniq x)) } ->
typing g (pack_ln (Tv_Var x)) (T.E_Total, Some?.v (lookup_bvar g (namedv_uniq x)))
| T_FVar :
g:env ->
x:fv { Some? (lookup_fvar g x) } ->
typing g (pack_ln (Tv_FVar x)) (T.E_Total, Some?.v (lookup_fvar g x))
| T_UInst :
g:env ->
x:fv ->
us:list universe { Some? (lookup_fvar_uinst g x us) } ->
typing g (pack_ln (Tv_UInst x us)) (T.E_Total, Some?.v (lookup_fvar_uinst g x us))
| T_Const:
g:env ->
v:vconst ->
t:term ->
constant_typing v t ->
typing g (constant_as_term v) (T.E_Total, t)
| T_Abs :
g:env ->
x:var { None? (lookup_bvar g x) } ->
ty:term ->
body:term { ~(x `Set.mem` freevars body) } ->
body_c:comp_typ ->
u:universe ->
pp_name:pp_name_t ->
q:aqualv ->
ty_eff:T.tot_or_ghost ->
typing g ty (ty_eff, tm_type u) ->
typing (extend_env g x ty) (open_term body x) body_c ->
typing g (pack_ln (Tv_Abs (mk_binder pp_name ty q) body))
(T.E_Total,
pack_ln (Tv_Arrow (mk_binder pp_name ty q)
(mk_comp (close_comp_typ body_c x))))
| T_App :
g:env ->
e1:term ->
e2:term ->
x:binder ->
t:term ->
eff:T.tot_or_ghost ->
typing g e1 (eff, pack_ln (Tv_Arrow x (mk_comp (eff, t)))) ->
typing g e2 (eff, binder_sort x) ->
typing g (pack_ln (Tv_App e1 (e2, binder_qual x)))
(eff, open_with t e2)
| T_Let:
g:env ->
x:var { None? (lookup_bvar g x) } ->
e1:term ->
t1:typ ->
e2:term ->
t2:typ ->
eff:T.tot_or_ghost ->
pp_name:pp_name_t ->
typing g e1 (eff, t1) ->
typing (extend_env g x t1) (open_term e2 x) (eff, t2) ->
typing g (mk_let pp_name e1 t1 e2) (eff, open_with (close_term t2 x) e1)
| T_Arrow:
g:env ->
x:var { None? (lookup_bvar g x) } ->
t1:term ->
t2:term { ~(x `Set.mem` freevars t2) } ->
u1:universe ->
u2:universe ->
pp_name:pp_name_t ->
q:aqualv ->
eff:T.tot_or_ghost ->
t1_eff:T.tot_or_ghost ->
t2_eff:T.tot_or_ghost ->
typing g t1 (t1_eff, tm_type u1) ->
typing (extend_env g x t1) (open_term t2 x) (t2_eff, tm_type u2) ->
typing g (pack_ln (Tv_Arrow (mk_binder pp_name t1 q) (mk_comp (eff, t2))))
(T.E_Total, tm_type (u_max u1 u2))
| T_Refine:
g:env ->
x:var { None? (lookup_bvar g x) } ->
t:term ->
e:term { ~(x `Set.mem` freevars e) } ->
u1:universe ->
u2:universe ->
t_eff:T.tot_or_ghost ->
e_eff:T.tot_or_ghost ->
typing g t (t_eff, tm_type u1) ->
typing (extend_env g x t) (open_term e x) (e_eff, tm_type u2) ->
typing g (pack_ln (Tv_Refine (mk_simple_binder pp_name_default t) e)) (T.E_Total, tm_type u1)
| T_PropIrrelevance:
g:env ->
e:term ->
t:term ->
e_eff:T.tot_or_ghost ->
t_eff:T.tot_or_ghost ->
typing g e (e_eff, t) ->
typing g t (t_eff, tm_prop) ->
typing g (`()) (T.E_Total, t)
| T_Sub:
g:env ->
e:term ->
c:comp_typ ->
c':comp_typ ->
typing g e c ->
sub_comp g c c' ->
typing g e c'
| T_If:
g:env ->
scrutinee:term ->
then_:term ->
else_:term ->
ty:term ->
u_ty:universe ->
hyp:var { None? (lookup_bvar g hyp) /\ ~(hyp `Set.mem` (freevars then_ `Set.union` freevars else_)) } ->
eff:T.tot_or_ghost ->
ty_eff:T.tot_or_ghost ->
typing g scrutinee (eff, bool_ty) ->
typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee true_bool)) then_ (eff, ty) ->
typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee false_bool)) else_ (eff, ty) ->
typing g ty (ty_eff, tm_type u_ty) -> //typedness of ty cannot rely on hyp
typing g (mk_if scrutinee then_ else_) (eff, ty)
| T_Match:
g:env ->
sc_u : universe ->
sc_ty : typ ->
sc : term ->
ty_eff:T.tot_or_ghost ->
typing g sc_ty (ty_eff, tm_type sc_u) ->
eff:T.tot_or_ghost ->
typing g sc (eff, sc_ty) ->
branches:list branch ->
ty:comp_typ ->
bnds:list (list R.binding) ->
complet : match_is_complete g sc sc_ty (List.Tot.map fst branches) bnds -> // complete patterns
branches_typing g sc_u sc_ty sc ty branches bnds -> // each branch has proper type
typing g (pack_ln (Tv_Match sc None branches)) ty
and related : env -> term -> relation -> term -> Type0 =
| Rel_refl:
g:env ->
t:term ->
rel:relation ->
related g t rel t
| Rel_sym:
g:env ->
t0:term ->
t1:term ->
related g t0 R_Eq t1 ->
related g t1 R_Eq t0
| Rel_trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
rel:relation ->
related g t0 rel t1 ->
related g t1 rel t2 ->
related g t0 rel t2
| Rel_univ:
g:env ->
u:universe ->
v:universe ->
univ_eq u v ->
related g (tm_type u) R_Eq (tm_type v)
| Rel_beta:
g:env ->
t:typ ->
q:aqualv ->
e:term { ln' e 0 } ->
arg:term { ln arg } ->
related g (R.pack_ln (R.Tv_App (mk_abs t q e) (arg, q)))
R_Eq
(subst_term e [ DT 0 arg ])
| Rel_eq_token:
g:env ->
t0:term ->
t1:term ->
squash (T.equiv_token g t0 t1) ->
related g t0 R_Eq t1
| Rel_subtyping_token:
g:env ->
t0:term ->
t1:term ->
squash (T.subtyping_token g t0 t1) ->
related g t0 R_Sub t1
| Rel_equiv:
g:env ->
t0:term ->
t1:term ->
rel:relation ->
related g t0 R_Eq t1 ->
related g t0 rel t1
| Rel_arrow:
g:env ->
t1:term ->
t2:term ->
q:aqualv ->
c1:comp_typ ->
c2:comp_typ ->
rel:relation ->
x:var{
None? (lookup_bvar g x) /\
~ (x `Set.mem` (freevars_comp_typ c1 `Set.union` freevars_comp_typ c2))
} ->
related g t2 rel t1 ->
related_comp (extend_env g x t2)
(open_comp_typ c1 x)
rel
(open_comp_typ c2 x) ->
related g (mk_arrow_ct t1 q c1) rel (mk_arrow_ct t2 q c2)
| Rel_abs:
g:env ->
t1:term ->
t2:term ->
q:aqualv ->
e1:term ->
e2:term ->
x:var{
None? (lookup_bvar g x) /\ ~ (x `Set.mem` (freevars e1 `Set.union` freevars e2))
} ->
related g t1 R_Eq t2 ->
related (extend_env g x t1)
(subst_term e1 (open_with_var x 0))
R_Eq
(subst_term e2 (open_with_var x 0)) ->
related g (mk_abs t1 q e1) R_Eq (mk_abs t2 q e2)
| Rel_ctxt:
g:env ->
t0:term ->
t1:term ->
ctxt:term_ctxt ->
related g t0 R_Eq t1 ->
related g (apply_term_ctxt ctxt t0) R_Eq (apply_term_ctxt ctxt t1)
and related_comp : env -> comp_typ -> relation -> comp_typ -> Type0 =
| Relc_typ:
g:env ->
t0:term ->
t1:term ->
eff:T.tot_or_ghost ->
rel:relation ->
related g t0 rel t1 ->
related_comp g (eff, t0) rel (eff, t1)
| Relc_total_ghost:
g:env ->
t:term ->
related_comp g (T.E_Total, t) R_Sub (T.E_Ghost, t)
| Relc_ghost_total:
g:env ->
t:term ->
non_informative g t ->
related_comp g (T.E_Ghost, t) R_Sub (T.E_Total, t)
and branches_typing (g:env) (sc_u:universe) (sc_ty:typ) (sc:term) (rty:comp_typ)
: (brs:list branch) -> (bnds : list (list R.binding)) -> Type0
=
(* This judgement only enforces that branch_typing holds for every
element of brs and its respective bnds (which must have the same
length). *)
| BT_Nil :
branches_typing g sc_u sc_ty sc rty [] []
| BT_S :
br : branch ->
bnds : list R.binding ->
pf : branch_typing g sc_u sc_ty sc rty br bnds ->
rest_br : list branch ->
rest_bnds : list (list R.binding) ->
rest : branches_typing g sc_u sc_ty sc rty rest_br rest_bnds ->
branches_typing g sc_u sc_ty sc rty (br :: rest_br) (bnds :: rest_bnds)
and branch_typing (g:env) (sc_u:universe) (sc_ty:typ) (sc:term) (rty:comp_typ)
: (br : branch) -> (bnds : list R.binding) -> Type0
=
| BO :
pat : pattern ->
bnds : list R.binding{bindings_ok_for_pat g bnds pat} ->
hyp_var:var{None? (lookup_bvar (extend_env_l g (refl_bindings_to_bindings bnds)) hyp_var)} ->
body:term ->
_ : squash (Some? (elaborate_pat pat bnds)) ->
typing (extend_env
(extend_env_l g (refl_bindings_to_bindings bnds))
hyp_var (eq2 sc_u sc_ty sc (fst (Some?.v (elaborate_pat pat bnds))))
)
body rty ->
branch_typing g sc_u sc_ty sc rty
(pat, close_term_bs (refl_bindings_to_bindings bnds) body)
bnds
and match_is_complete : env -> term -> typ -> list pattern -> list (list R.binding) -> Type0 =
| MC_Tok :
env:_ ->
sc:_ ->
ty:_ ->
pats:_ ->
bnds:_ ->
squash (T.match_complete_token env sc ty pats bnds) -> match_is_complete env sc ty pats bnds
and sub_typing (g:env) (t1 t2:term) = related g t1 R_Sub t2
and sub_comp (g:env) (c1 c2:comp_typ) = related_comp g c1 R_Sub c2
and equiv (g:env) (t1 t2:term) = related g t1 R_Eq t2
type tot_typing (g:env) (e:term) (t:term) = typing g e (T.E_Total, t)
type ghost_typing (g:env) (e:term) (t:term) = typing g e (T.E_Ghost, t)
val subtyping_token_renaming (g:env)
(bs0:bindings)
(bs1:bindings)
(x:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) x) })
(y:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) y) })
(t:term)
(t0 t1:term)
(d:T.subtyping_token (extend_env_l g (bs1@(x,t)::bs0)) t0 t1)
: T.subtyping_token (extend_env_l g (rename_bindings bs1 x y@(y,t)::bs0))
(rename t0 x y)
(rename t1 x y)
val subtyping_token_weakening (g:env)
(bs0:bindings)
(bs1:bindings)
(x:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) x) })
(t:term)
(t0 t1:term)
(d:T.subtyping_token (extend_env_l g (bs1@bs0)) t0 t1)
: T.subtyping_token (extend_env_l g (bs1@(x,t)::bs0)) t0 t1
let simplify_umax (#g:R.env) (#t:R.term) (#u:R.universe)
(d:typing g t (T.E_Total, tm_type (u_max u u))) | false | false | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val simplify_umax
(#g: R.env)
(#t: R.term)
(#u: R.universe)
(d: typing g t (T.E_Total, tm_type (u_max u u)))
: typing g t (T.E_Total, tm_type u) | [] | FStar.Reflection.Typing.simplify_umax | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
d:
FStar.Reflection.Typing.typing g
t
(FStar.Stubs.TypeChecker.Core.E_Total,
FStar.Reflection.Typing.tm_type (FStar.Reflection.Typing.u_max u494 u494))
-> FStar.Reflection.Typing.typing g
t
(FStar.Stubs.TypeChecker.Core.E_Total, FStar.Reflection.Typing.tm_type u494) | {
"end_col": 52,
"end_line": 1524,
"start_col": 4,
"start_line": 1516
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let dsl_tac_result_t (g:env) = list (sigelt_for g) | let dsl_tac_result_t (g: env) = | false | null | false | list (sigelt_for g) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.env",
"Prims.list",
"FStar.Reflection.Typing.sigelt_for"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"]
let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f)
let rec __close_term_vs (i:nat) (vs : list var) (t : term) : Tot term (decreases vs) =
match vs with
| [] -> t
| v::vs ->
subst_term (__close_term_vs (i+1) vs t) [ND v i]
let close_term_vs (vs : list var) (t : term) : term =
__close_term_vs 0 vs t
let close_term_bs (bs : list binding) (t : term) : term =
close_term_vs (List.Tot.map fst bs) t
let bindings_to_refl_bindings (bs : list binding) : list R.binding =
L.map (fun (v, ty) -> {uniq=v; sort=ty; ppname = pp_name_default}) bs
let refl_bindings_to_bindings (bs : list R.binding) : list binding =
L.map (fun b -> b.uniq, b.sort) bs
[@@ no_auto_projectors]
noeq
type non_informative : env -> term -> Type0 =
| Non_informative_type:
g:env ->
u:universe ->
non_informative g (pack_ln (Tv_Type u))
| Non_informative_fv:
g:env ->
x:fv{is_non_informative_fv x} ->
non_informative g (pack_ln (Tv_FVar x))
| Non_informative_uinst:
g:env ->
x:fv{is_non_informative_fv x} ->
us:list universe ->
non_informative g (pack_ln (Tv_UInst x us))
| Non_informative_app:
g:env ->
t:term ->
arg:argv ->
non_informative g t ->
non_informative g (pack_ln (Tv_App t arg))
| Non_informative_total_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g t1 ->
non_informative g (mk_arrow_ct t0 q (T.E_Total, t1))
| Non_informative_ghost_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g (mk_arrow_ct t0 q (T.E_Ghost, t1))
| Non_informative_token:
g:env ->
t:typ ->
squash (T.non_informative_token g t) ->
non_informative g t
val bindings_ok_for_pat : env -> list R.binding -> pattern -> Type0
val bindings_ok_pat_constant :
g:env -> c:R.vconst -> Lemma (bindings_ok_for_pat g [] (Pat_Constant c))
let bindings_ok_for_branch (g:env) (bs : list R.binding) (br : branch) : Type0 =
bindings_ok_for_pat g bs (fst br)
let bindings_ok_for_branch_N (g:env) (bss : list (list R.binding)) (brs : list branch) =
zip2prop (bindings_ok_for_branch g) bss brs
let binding_to_namedv (b:R.binding) : Tot namedv =
pack_namedv {
RD.uniq = b.uniq;
RD.sort = seal b.sort;
RD.ppname = b.ppname;
}
(* Elaborates the p pattern into a term, using the bs bindings for the
pattern variables. The resulting term is properly scoped only on an
environment which contains all of bs. See for instance the branch_typing
judg. Returns an option, since this can fail if e.g. there are not
enough bindings, and returns the list of unused binders as well, which
should be empty if the list of binding was indeed ok. *)
let rec elaborate_pat (p : pattern) (bs : list R.binding) : Tot (option (term & list R.binding)) (decreases p) =
match p, bs with
| Pat_Constant c, _ -> Some (pack_ln (Tv_Const c), bs)
| Pat_Cons fv univs subpats, bs ->
let head = pack_ln (Tv_FVar fv) in
fold_left_dec
(Some (head, bs))
subpats
(fun st pi ->
let (p,i) = pi in
match st with | None -> None | Some (head, bs) ->
match elaborate_pat p bs with | None -> None | Some (t, bs') -> Some (pack_ln (Tv_App head (t, (if i then Q_Implicit else Q_Explicit))), bs'))
| Pat_Var _ _, b::bs ->
Some (pack_ln (Tv_Var (binding_to_namedv b)), bs)
| Pat_Dot_Term (Some t), _ -> Some (t, bs)
| Pat_Dot_Term None, _ -> None
| _ -> None
[@@ no_auto_projectors]
noeq
type typing : env -> term -> comp_typ -> Type0 =
| T_Token :
g:env ->
e:term ->
c:comp_typ ->
squash (T.typing_token g e c) ->
typing g e c
| T_Var :
g:env ->
x:namedv { Some? (lookup_bvar g (namedv_uniq x)) } ->
typing g (pack_ln (Tv_Var x)) (T.E_Total, Some?.v (lookup_bvar g (namedv_uniq x)))
| T_FVar :
g:env ->
x:fv { Some? (lookup_fvar g x) } ->
typing g (pack_ln (Tv_FVar x)) (T.E_Total, Some?.v (lookup_fvar g x))
| T_UInst :
g:env ->
x:fv ->
us:list universe { Some? (lookup_fvar_uinst g x us) } ->
typing g (pack_ln (Tv_UInst x us)) (T.E_Total, Some?.v (lookup_fvar_uinst g x us))
| T_Const:
g:env ->
v:vconst ->
t:term ->
constant_typing v t ->
typing g (constant_as_term v) (T.E_Total, t)
| T_Abs :
g:env ->
x:var { None? (lookup_bvar g x) } ->
ty:term ->
body:term { ~(x `Set.mem` freevars body) } ->
body_c:comp_typ ->
u:universe ->
pp_name:pp_name_t ->
q:aqualv ->
ty_eff:T.tot_or_ghost ->
typing g ty (ty_eff, tm_type u) ->
typing (extend_env g x ty) (open_term body x) body_c ->
typing g (pack_ln (Tv_Abs (mk_binder pp_name ty q) body))
(T.E_Total,
pack_ln (Tv_Arrow (mk_binder pp_name ty q)
(mk_comp (close_comp_typ body_c x))))
| T_App :
g:env ->
e1:term ->
e2:term ->
x:binder ->
t:term ->
eff:T.tot_or_ghost ->
typing g e1 (eff, pack_ln (Tv_Arrow x (mk_comp (eff, t)))) ->
typing g e2 (eff, binder_sort x) ->
typing g (pack_ln (Tv_App e1 (e2, binder_qual x)))
(eff, open_with t e2)
| T_Let:
g:env ->
x:var { None? (lookup_bvar g x) } ->
e1:term ->
t1:typ ->
e2:term ->
t2:typ ->
eff:T.tot_or_ghost ->
pp_name:pp_name_t ->
typing g e1 (eff, t1) ->
typing (extend_env g x t1) (open_term e2 x) (eff, t2) ->
typing g (mk_let pp_name e1 t1 e2) (eff, open_with (close_term t2 x) e1)
| T_Arrow:
g:env ->
x:var { None? (lookup_bvar g x) } ->
t1:term ->
t2:term { ~(x `Set.mem` freevars t2) } ->
u1:universe ->
u2:universe ->
pp_name:pp_name_t ->
q:aqualv ->
eff:T.tot_or_ghost ->
t1_eff:T.tot_or_ghost ->
t2_eff:T.tot_or_ghost ->
typing g t1 (t1_eff, tm_type u1) ->
typing (extend_env g x t1) (open_term t2 x) (t2_eff, tm_type u2) ->
typing g (pack_ln (Tv_Arrow (mk_binder pp_name t1 q) (mk_comp (eff, t2))))
(T.E_Total, tm_type (u_max u1 u2))
| T_Refine:
g:env ->
x:var { None? (lookup_bvar g x) } ->
t:term ->
e:term { ~(x `Set.mem` freevars e) } ->
u1:universe ->
u2:universe ->
t_eff:T.tot_or_ghost ->
e_eff:T.tot_or_ghost ->
typing g t (t_eff, tm_type u1) ->
typing (extend_env g x t) (open_term e x) (e_eff, tm_type u2) ->
typing g (pack_ln (Tv_Refine (mk_simple_binder pp_name_default t) e)) (T.E_Total, tm_type u1)
| T_PropIrrelevance:
g:env ->
e:term ->
t:term ->
e_eff:T.tot_or_ghost ->
t_eff:T.tot_or_ghost ->
typing g e (e_eff, t) ->
typing g t (t_eff, tm_prop) ->
typing g (`()) (T.E_Total, t)
| T_Sub:
g:env ->
e:term ->
c:comp_typ ->
c':comp_typ ->
typing g e c ->
sub_comp g c c' ->
typing g e c'
| T_If:
g:env ->
scrutinee:term ->
then_:term ->
else_:term ->
ty:term ->
u_ty:universe ->
hyp:var { None? (lookup_bvar g hyp) /\ ~(hyp `Set.mem` (freevars then_ `Set.union` freevars else_)) } ->
eff:T.tot_or_ghost ->
ty_eff:T.tot_or_ghost ->
typing g scrutinee (eff, bool_ty) ->
typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee true_bool)) then_ (eff, ty) ->
typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee false_bool)) else_ (eff, ty) ->
typing g ty (ty_eff, tm_type u_ty) -> //typedness of ty cannot rely on hyp
typing g (mk_if scrutinee then_ else_) (eff, ty)
| T_Match:
g:env ->
sc_u : universe ->
sc_ty : typ ->
sc : term ->
ty_eff:T.tot_or_ghost ->
typing g sc_ty (ty_eff, tm_type sc_u) ->
eff:T.tot_or_ghost ->
typing g sc (eff, sc_ty) ->
branches:list branch ->
ty:comp_typ ->
bnds:list (list R.binding) ->
complet : match_is_complete g sc sc_ty (List.Tot.map fst branches) bnds -> // complete patterns
branches_typing g sc_u sc_ty sc ty branches bnds -> // each branch has proper type
typing g (pack_ln (Tv_Match sc None branches)) ty
and related : env -> term -> relation -> term -> Type0 =
| Rel_refl:
g:env ->
t:term ->
rel:relation ->
related g t rel t
| Rel_sym:
g:env ->
t0:term ->
t1:term ->
related g t0 R_Eq t1 ->
related g t1 R_Eq t0
| Rel_trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
rel:relation ->
related g t0 rel t1 ->
related g t1 rel t2 ->
related g t0 rel t2
| Rel_univ:
g:env ->
u:universe ->
v:universe ->
univ_eq u v ->
related g (tm_type u) R_Eq (tm_type v)
| Rel_beta:
g:env ->
t:typ ->
q:aqualv ->
e:term { ln' e 0 } ->
arg:term { ln arg } ->
related g (R.pack_ln (R.Tv_App (mk_abs t q e) (arg, q)))
R_Eq
(subst_term e [ DT 0 arg ])
| Rel_eq_token:
g:env ->
t0:term ->
t1:term ->
squash (T.equiv_token g t0 t1) ->
related g t0 R_Eq t1
| Rel_subtyping_token:
g:env ->
t0:term ->
t1:term ->
squash (T.subtyping_token g t0 t1) ->
related g t0 R_Sub t1
| Rel_equiv:
g:env ->
t0:term ->
t1:term ->
rel:relation ->
related g t0 R_Eq t1 ->
related g t0 rel t1
| Rel_arrow:
g:env ->
t1:term ->
t2:term ->
q:aqualv ->
c1:comp_typ ->
c2:comp_typ ->
rel:relation ->
x:var{
None? (lookup_bvar g x) /\
~ (x `Set.mem` (freevars_comp_typ c1 `Set.union` freevars_comp_typ c2))
} ->
related g t2 rel t1 ->
related_comp (extend_env g x t2)
(open_comp_typ c1 x)
rel
(open_comp_typ c2 x) ->
related g (mk_arrow_ct t1 q c1) rel (mk_arrow_ct t2 q c2)
| Rel_abs:
g:env ->
t1:term ->
t2:term ->
q:aqualv ->
e1:term ->
e2:term ->
x:var{
None? (lookup_bvar g x) /\ ~ (x `Set.mem` (freevars e1 `Set.union` freevars e2))
} ->
related g t1 R_Eq t2 ->
related (extend_env g x t1)
(subst_term e1 (open_with_var x 0))
R_Eq
(subst_term e2 (open_with_var x 0)) ->
related g (mk_abs t1 q e1) R_Eq (mk_abs t2 q e2)
| Rel_ctxt:
g:env ->
t0:term ->
t1:term ->
ctxt:term_ctxt ->
related g t0 R_Eq t1 ->
related g (apply_term_ctxt ctxt t0) R_Eq (apply_term_ctxt ctxt t1)
and related_comp : env -> comp_typ -> relation -> comp_typ -> Type0 =
| Relc_typ:
g:env ->
t0:term ->
t1:term ->
eff:T.tot_or_ghost ->
rel:relation ->
related g t0 rel t1 ->
related_comp g (eff, t0) rel (eff, t1)
| Relc_total_ghost:
g:env ->
t:term ->
related_comp g (T.E_Total, t) R_Sub (T.E_Ghost, t)
| Relc_ghost_total:
g:env ->
t:term ->
non_informative g t ->
related_comp g (T.E_Ghost, t) R_Sub (T.E_Total, t)
and branches_typing (g:env) (sc_u:universe) (sc_ty:typ) (sc:term) (rty:comp_typ)
: (brs:list branch) -> (bnds : list (list R.binding)) -> Type0
=
(* This judgement only enforces that branch_typing holds for every
element of brs and its respective bnds (which must have the same
length). *)
| BT_Nil :
branches_typing g sc_u sc_ty sc rty [] []
| BT_S :
br : branch ->
bnds : list R.binding ->
pf : branch_typing g sc_u sc_ty sc rty br bnds ->
rest_br : list branch ->
rest_bnds : list (list R.binding) ->
rest : branches_typing g sc_u sc_ty sc rty rest_br rest_bnds ->
branches_typing g sc_u sc_ty sc rty (br :: rest_br) (bnds :: rest_bnds)
and branch_typing (g:env) (sc_u:universe) (sc_ty:typ) (sc:term) (rty:comp_typ)
: (br : branch) -> (bnds : list R.binding) -> Type0
=
| BO :
pat : pattern ->
bnds : list R.binding{bindings_ok_for_pat g bnds pat} ->
hyp_var:var{None? (lookup_bvar (extend_env_l g (refl_bindings_to_bindings bnds)) hyp_var)} ->
body:term ->
_ : squash (Some? (elaborate_pat pat bnds)) ->
typing (extend_env
(extend_env_l g (refl_bindings_to_bindings bnds))
hyp_var (eq2 sc_u sc_ty sc (fst (Some?.v (elaborate_pat pat bnds))))
)
body rty ->
branch_typing g sc_u sc_ty sc rty
(pat, close_term_bs (refl_bindings_to_bindings bnds) body)
bnds
and match_is_complete : env -> term -> typ -> list pattern -> list (list R.binding) -> Type0 =
| MC_Tok :
env:_ ->
sc:_ ->
ty:_ ->
pats:_ ->
bnds:_ ->
squash (T.match_complete_token env sc ty pats bnds) -> match_is_complete env sc ty pats bnds
and sub_typing (g:env) (t1 t2:term) = related g t1 R_Sub t2
and sub_comp (g:env) (c1 c2:comp_typ) = related_comp g c1 R_Sub c2
and equiv (g:env) (t1 t2:term) = related g t1 R_Eq t2
type tot_typing (g:env) (e:term) (t:term) = typing g e (T.E_Total, t)
type ghost_typing (g:env) (e:term) (t:term) = typing g e (T.E_Ghost, t)
val subtyping_token_renaming (g:env)
(bs0:bindings)
(bs1:bindings)
(x:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) x) })
(y:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) y) })
(t:term)
(t0 t1:term)
(d:T.subtyping_token (extend_env_l g (bs1@(x,t)::bs0)) t0 t1)
: T.subtyping_token (extend_env_l g (rename_bindings bs1 x y@(y,t)::bs0))
(rename t0 x y)
(rename t1 x y)
val subtyping_token_weakening (g:env)
(bs0:bindings)
(bs1:bindings)
(x:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) x) })
(t:term)
(t0 t1:term)
(d:T.subtyping_token (extend_env_l g (bs1@bs0)) t0 t1)
: T.subtyping_token (extend_env_l g (bs1@(x,t)::bs0)) t0 t1
let simplify_umax (#g:R.env) (#t:R.term) (#u:R.universe)
(d:typing g t (T.E_Total, tm_type (u_max u u)))
: typing g t (T.E_Total, tm_type u)
= let ue
: univ_eq (u_max u u) u
= UN_MaxLeq u u (UNLEQ_Refl u)
in
let du : related g (tm_type (u_max u u)) R_Eq (tm_type u)
= Rel_univ g (u_max u u) u ue in
let du : related g (tm_type (u_max u u)) R_Sub (tm_type u)
= Rel_equiv _ _ _ _ du in
T_Sub _ _ _ _ d (Relc_typ _ _ _ T.E_Total _ du)
val well_typed_terms_are_ln (g:R.env) (e:R.term) (c:comp_typ) (_:typing g e c)
: Lemma (ensures ln e /\ ln (snd c))
val type_correctness (g:R.env) (e:R.term) (c:comp_typ) (_:typing g e c)
: GTot (u:R.universe & typing g (snd c) (T.E_Total, tm_type u))
val binder_offset_pattern_invariant (p:pattern) (ss:subst)
: Lemma (binder_offset_pattern p == binder_offset_pattern (subst_pattern p ss))
val binder_offset_patterns_invariant (p:list (pattern & bool)) (ss:subst)
: Lemma (binder_offset_patterns p == binder_offset_patterns (subst_patterns p ss))
val open_close_inverse' (i:nat) (t:term { ln' t (i - 1) }) (x:var)
: Lemma
(ensures subst_term
(subst_term t [ ND x i ])
(open_with_var x i)
== t)
val open_close_inverse'_binder (i:nat) (b:binder { ln'_binder b (i - 1) }) (x:var)
: Lemma (ensures subst_binder
(subst_binder b [ ND x i ])
(open_with_var x i)
== b)
val open_close_inverse'_terms (i:nat) (ts:list term { ln'_terms ts (i - 1) }) (x:var)
: Lemma (ensures subst_terms
(subst_terms ts [ ND x i ])
(open_with_var x i)
== ts)
val open_close_inverse'_comp (i:nat) (c:comp { ln'_comp c (i - 1) }) (x:var)
: Lemma
(ensures subst_comp
(subst_comp c [ ND x i ])
(open_with_var x i)
== c)
val open_close_inverse'_args (i:nat)
(ts:list argv { ln'_args ts (i - 1) })
(x:var)
: Lemma
(ensures subst_args
(subst_args ts [ ND x i ])
(open_with_var x i)
== ts)
val open_close_inverse'_patterns (i:nat)
(ps:list (pattern & bool) { ln'_patterns ps (i - 1) })
(x:var)
: Lemma
(ensures subst_patterns
(subst_patterns ps [ ND x i ])
(open_with_var x i)
== ps)
val open_close_inverse'_pattern (i:nat) (p:pattern{ln'_pattern p (i - 1)}) (x:var)
: Lemma
(ensures subst_pattern
(subst_pattern p [ ND x i ])
(open_with_var x i)
== p)
val open_close_inverse'_branch (i:nat) (br:branch{ln'_branch br (i - 1)}) (x:var)
: Lemma
(ensures subst_branch
(subst_branch br [ ND x i ])
(open_with_var x i)
== br)
val open_close_inverse'_branches (i:nat)
(brs:list branch { ln'_branches brs (i - 1) })
(x:var)
: Lemma
(ensures subst_branches
(subst_branches brs [ ND x i ])
(open_with_var x i)
== brs)
val open_close_inverse'_match_returns (i:nat)
(m:match_returns_ascription { ln'_match_returns m (i - 1) })
(x:var)
: Lemma
(ensures subst_match_returns
(subst_match_returns m [ ND x i ])
(open_with_var x i)
== m)
val open_close_inverse (e:R.term { ln e }) (x:var)
: Lemma (open_term (close_term e x) x == e)
val close_open_inverse' (i:nat)
(t:term)
(x:var { ~(x `Set.mem` freevars t) })
: Lemma
(ensures subst_term
(subst_term t (open_with_var x i))
[ ND x i ]
== t)
val close_open_inverse'_comp (i:nat)
(c:comp)
(x:var{ ~(x `Set.mem` freevars_comp c) })
: Lemma
(ensures subst_comp
(subst_comp c (open_with_var x i))
[ ND x i ]
== c)
val close_open_inverse'_args (i:nat) (args:list argv) (x:var{ ~(x `Set.mem` freevars_args args) })
: Lemma
(ensures subst_args
(subst_args args (open_with_var x i))
[ ND x i]
== args)
val close_open_inverse'_binder (i:nat) (b:binder) (x:var{ ~(x `Set.mem` freevars_binder b) })
: Lemma
(ensures subst_binder
(subst_binder b (open_with_var x i))
[ ND x i ]
== b)
val close_open_inverse'_terms (i:nat) (ts:list term) (x:var{ ~(x `Set.mem` freevars_terms ts) })
: Lemma
(ensures subst_terms
(subst_terms ts (open_with_var x i))
[ ND x i ]
== ts)
val close_open_inverse'_branches (i:nat) (brs:list branch)
(x:var{ ~(x `Set.mem` freevars_branches brs) })
: Lemma
(ensures subst_branches
(subst_branches brs (open_with_var x i))
[ ND x i ]
== brs)
val close_open_inverse'_branch (i:nat)
(br:branch)
(x:var{ ~(x `Set.mem` freevars_branch br) })
: Lemma
(ensures subst_branch
(subst_branch br (open_with_var x i))
[ ND x i ]
== br)
val close_open_inverse'_pattern (i:nat)
(p:pattern)
(x:var{ ~(x `Set.mem` freevars_pattern p) })
: Lemma
(ensures subst_pattern
(subst_pattern p (open_with_var x i))
[ ND x i ]
== p)
val close_open_inverse'_patterns (i:nat)
(ps:list (pattern & bool))
(x:var {~ (x `Set.mem` freevars_patterns ps) })
: Lemma
(ensures subst_patterns
(subst_patterns ps (open_with_var x i))
[ ND x i ]
== ps)
val close_open_inverse'_match_returns (i:nat) (m:match_returns_ascription)
(x:var{ ~(x `Set.mem` freevars_match_returns m) })
: Lemma
(ensures subst_match_returns
(subst_match_returns m (open_with_var x i))
[ ND x i ]
== m)
val close_open_inverse (e:R.term) (x:var {~ (x `Set.mem` freevars e) })
: Lemma (close_term (open_term e x) x == e)
//
// fst has corresponding lemmas for other syntax classes
//
val close_with_not_free_var (t:R.term) (x:var) (i:nat)
: Lemma
(requires ~ (Set.mem x (freevars t)))
(ensures subst_term t [ ND x i ] == t)
// this also requires x to be not in freevars e1 `Set.union` freevars e2
val equiv_arrow (#g:R.env) (#e1 #e2:R.term) (ty:R.typ) (q:R.aqualv)
(x:var { None? (lookup_bvar g x) })
(eq:equiv (extend_env g x ty)
(subst_term e1 (open_with_var x 0))
(subst_term e2 (open_with_var x 0)))
: equiv g (mk_arrow ty q e1)
(mk_arrow ty q e2)
// the proof for this requires e1 and e2 to be ln
val equiv_abs_close (#g:R.env) (#e1 #e2:R.term) (ty:R.typ) (q:R.aqualv)
(x:var{None? (lookup_bvar g x)})
(eq:equiv (extend_env g x ty) e1 e2)
: equiv g (mk_abs ty q (subst_term e1 [ ND x 0 ]))
(mk_abs ty q (subst_term e2 [ ND x 0 ]))
val open_with_gt_ln (e:term) (i:nat) (t:term) (j:nat)
: Lemma
(requires ln' e i /\ i < j)
(ensures subst_term e [ DT j t ] == e)
[SMTPat (ln' e i); SMTPat (subst_term e [ DT j t ])]
//
// Type of the top-level tactic that would splice-in the definitions
//
let fstar_env_fvs (g:R.env) =
lookup_fvar g unit_fv == Some (tm_type u_zero) /\
lookup_fvar g bool_fv == Some (tm_type u_zero) /\
lookup_fvar g b2t_fv == Some b2t_ty
type fstar_env = g:R.env{fstar_env_fvs g}
type fstar_top_env = g:fstar_env {
forall x. None? (lookup_bvar g x )
}
//
// This doesn't allow for universe polymorphic definitions
//
// May be we can change it to:
//
// g:fstar_top_env -> T.tac ((us, e, t):(univ_names & term & typ){typing (push g us) e t})
//
noeq
type sigelt_typing : env -> sigelt -> Type0 =
| ST_Let :
g : env ->
fv : R.fv ->
ty : R.typ ->
tm : R.term ->
squash (typing g tm (T.E_Total, ty)) ->
sigelt_typing g (pack_sigelt (Sg_Let false [pack_lb ({ lb_fv = fv; lb_us = []; lb_typ = ty; lb_def = tm })]))
| ST_Let_Opaque :
g : env ->
fv : R.fv ->
ty : R.typ ->
(* no tm: only a proof of existence *)
squash (exists (tm:R.term). typing g tm (T.E_Total, ty)) ->
sigelt_typing g (pack_sigelt (Sg_Let false [pack_lb ({ lb_fv = fv; lb_us = []; lb_typ = ty; lb_def = (`_) })]))
(**
* The type of the top-level tactic that would splice-in the definitions.
* It returns a list of well typed definitions, via the judgment above.
*
* Each definition can have a 'blob' attached with a given name.
* The blob can be used later, e.g., during extraction, and passed back to the
* extension to perform additional processing.
*)
(*
* It returns either:
* - Some tm, blob, typ, with a proof that `typing g tm typ`
* - None, blob, typ), with a proof that `exists tm. typing g tm typ`
* The blob itself is optional and can store some additional metadata that
* constructed by the tactic. If present, it will be stored in the
* sigmeta_extension_data field of the enclosing sigelt.
*
*)
let blob = string & R.term
(* If checked is true, this sigelt is properly typed for the environment. If not,
we don't know and let F* re-typecheck the sigelt. *)
let sigelt_for (g:env) =
tup:(bool & sigelt & option blob)
{
let (checked, se, _) = tup in
checked ==> sigelt_typing g se
} | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val dsl_tac_result_t : g: FStar.Reflection.Types.env -> Type0 | [] | FStar.Reflection.Typing.dsl_tac_result_t | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | g: FStar.Reflection.Types.env -> Type0 | {
"end_col": 50,
"end_line": 1803,
"start_col": 31,
"start_line": 1803
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sigelt_for (g:env) =
tup:(bool & sigelt & option blob)
{
let (checked, se, _) = tup in
checked ==> sigelt_typing g se
} | let sigelt_for (g: env) = | false | null | false | tup:
(bool & sigelt & option blob)
{ let checked, se, _ = tup in
checked ==> sigelt_typing g se } | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.env",
"FStar.Pervasives.Native.tuple3",
"Prims.bool",
"FStar.Reflection.Types.sigelt",
"FStar.Pervasives.Native.option",
"FStar.Reflection.Typing.blob",
"Prims.l_imp",
"Prims.b2t",
"FStar.Reflection.Typing.sigelt_typing"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"]
let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f)
let rec __close_term_vs (i:nat) (vs : list var) (t : term) : Tot term (decreases vs) =
match vs with
| [] -> t
| v::vs ->
subst_term (__close_term_vs (i+1) vs t) [ND v i]
let close_term_vs (vs : list var) (t : term) : term =
__close_term_vs 0 vs t
let close_term_bs (bs : list binding) (t : term) : term =
close_term_vs (List.Tot.map fst bs) t
let bindings_to_refl_bindings (bs : list binding) : list R.binding =
L.map (fun (v, ty) -> {uniq=v; sort=ty; ppname = pp_name_default}) bs
let refl_bindings_to_bindings (bs : list R.binding) : list binding =
L.map (fun b -> b.uniq, b.sort) bs
[@@ no_auto_projectors]
noeq
type non_informative : env -> term -> Type0 =
| Non_informative_type:
g:env ->
u:universe ->
non_informative g (pack_ln (Tv_Type u))
| Non_informative_fv:
g:env ->
x:fv{is_non_informative_fv x} ->
non_informative g (pack_ln (Tv_FVar x))
| Non_informative_uinst:
g:env ->
x:fv{is_non_informative_fv x} ->
us:list universe ->
non_informative g (pack_ln (Tv_UInst x us))
| Non_informative_app:
g:env ->
t:term ->
arg:argv ->
non_informative g t ->
non_informative g (pack_ln (Tv_App t arg))
| Non_informative_total_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g t1 ->
non_informative g (mk_arrow_ct t0 q (T.E_Total, t1))
| Non_informative_ghost_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g (mk_arrow_ct t0 q (T.E_Ghost, t1))
| Non_informative_token:
g:env ->
t:typ ->
squash (T.non_informative_token g t) ->
non_informative g t
val bindings_ok_for_pat : env -> list R.binding -> pattern -> Type0
val bindings_ok_pat_constant :
g:env -> c:R.vconst -> Lemma (bindings_ok_for_pat g [] (Pat_Constant c))
let bindings_ok_for_branch (g:env) (bs : list R.binding) (br : branch) : Type0 =
bindings_ok_for_pat g bs (fst br)
let bindings_ok_for_branch_N (g:env) (bss : list (list R.binding)) (brs : list branch) =
zip2prop (bindings_ok_for_branch g) bss brs
let binding_to_namedv (b:R.binding) : Tot namedv =
pack_namedv {
RD.uniq = b.uniq;
RD.sort = seal b.sort;
RD.ppname = b.ppname;
}
(* Elaborates the p pattern into a term, using the bs bindings for the
pattern variables. The resulting term is properly scoped only on an
environment which contains all of bs. See for instance the branch_typing
judg. Returns an option, since this can fail if e.g. there are not
enough bindings, and returns the list of unused binders as well, which
should be empty if the list of binding was indeed ok. *)
let rec elaborate_pat (p : pattern) (bs : list R.binding) : Tot (option (term & list R.binding)) (decreases p) =
match p, bs with
| Pat_Constant c, _ -> Some (pack_ln (Tv_Const c), bs)
| Pat_Cons fv univs subpats, bs ->
let head = pack_ln (Tv_FVar fv) in
fold_left_dec
(Some (head, bs))
subpats
(fun st pi ->
let (p,i) = pi in
match st with | None -> None | Some (head, bs) ->
match elaborate_pat p bs with | None -> None | Some (t, bs') -> Some (pack_ln (Tv_App head (t, (if i then Q_Implicit else Q_Explicit))), bs'))
| Pat_Var _ _, b::bs ->
Some (pack_ln (Tv_Var (binding_to_namedv b)), bs)
| Pat_Dot_Term (Some t), _ -> Some (t, bs)
| Pat_Dot_Term None, _ -> None
| _ -> None
[@@ no_auto_projectors]
noeq
type typing : env -> term -> comp_typ -> Type0 =
| T_Token :
g:env ->
e:term ->
c:comp_typ ->
squash (T.typing_token g e c) ->
typing g e c
| T_Var :
g:env ->
x:namedv { Some? (lookup_bvar g (namedv_uniq x)) } ->
typing g (pack_ln (Tv_Var x)) (T.E_Total, Some?.v (lookup_bvar g (namedv_uniq x)))
| T_FVar :
g:env ->
x:fv { Some? (lookup_fvar g x) } ->
typing g (pack_ln (Tv_FVar x)) (T.E_Total, Some?.v (lookup_fvar g x))
| T_UInst :
g:env ->
x:fv ->
us:list universe { Some? (lookup_fvar_uinst g x us) } ->
typing g (pack_ln (Tv_UInst x us)) (T.E_Total, Some?.v (lookup_fvar_uinst g x us))
| T_Const:
g:env ->
v:vconst ->
t:term ->
constant_typing v t ->
typing g (constant_as_term v) (T.E_Total, t)
| T_Abs :
g:env ->
x:var { None? (lookup_bvar g x) } ->
ty:term ->
body:term { ~(x `Set.mem` freevars body) } ->
body_c:comp_typ ->
u:universe ->
pp_name:pp_name_t ->
q:aqualv ->
ty_eff:T.tot_or_ghost ->
typing g ty (ty_eff, tm_type u) ->
typing (extend_env g x ty) (open_term body x) body_c ->
typing g (pack_ln (Tv_Abs (mk_binder pp_name ty q) body))
(T.E_Total,
pack_ln (Tv_Arrow (mk_binder pp_name ty q)
(mk_comp (close_comp_typ body_c x))))
| T_App :
g:env ->
e1:term ->
e2:term ->
x:binder ->
t:term ->
eff:T.tot_or_ghost ->
typing g e1 (eff, pack_ln (Tv_Arrow x (mk_comp (eff, t)))) ->
typing g e2 (eff, binder_sort x) ->
typing g (pack_ln (Tv_App e1 (e2, binder_qual x)))
(eff, open_with t e2)
| T_Let:
g:env ->
x:var { None? (lookup_bvar g x) } ->
e1:term ->
t1:typ ->
e2:term ->
t2:typ ->
eff:T.tot_or_ghost ->
pp_name:pp_name_t ->
typing g e1 (eff, t1) ->
typing (extend_env g x t1) (open_term e2 x) (eff, t2) ->
typing g (mk_let pp_name e1 t1 e2) (eff, open_with (close_term t2 x) e1)
| T_Arrow:
g:env ->
x:var { None? (lookup_bvar g x) } ->
t1:term ->
t2:term { ~(x `Set.mem` freevars t2) } ->
u1:universe ->
u2:universe ->
pp_name:pp_name_t ->
q:aqualv ->
eff:T.tot_or_ghost ->
t1_eff:T.tot_or_ghost ->
t2_eff:T.tot_or_ghost ->
typing g t1 (t1_eff, tm_type u1) ->
typing (extend_env g x t1) (open_term t2 x) (t2_eff, tm_type u2) ->
typing g (pack_ln (Tv_Arrow (mk_binder pp_name t1 q) (mk_comp (eff, t2))))
(T.E_Total, tm_type (u_max u1 u2))
| T_Refine:
g:env ->
x:var { None? (lookup_bvar g x) } ->
t:term ->
e:term { ~(x `Set.mem` freevars e) } ->
u1:universe ->
u2:universe ->
t_eff:T.tot_or_ghost ->
e_eff:T.tot_or_ghost ->
typing g t (t_eff, tm_type u1) ->
typing (extend_env g x t) (open_term e x) (e_eff, tm_type u2) ->
typing g (pack_ln (Tv_Refine (mk_simple_binder pp_name_default t) e)) (T.E_Total, tm_type u1)
| T_PropIrrelevance:
g:env ->
e:term ->
t:term ->
e_eff:T.tot_or_ghost ->
t_eff:T.tot_or_ghost ->
typing g e (e_eff, t) ->
typing g t (t_eff, tm_prop) ->
typing g (`()) (T.E_Total, t)
| T_Sub:
g:env ->
e:term ->
c:comp_typ ->
c':comp_typ ->
typing g e c ->
sub_comp g c c' ->
typing g e c'
| T_If:
g:env ->
scrutinee:term ->
then_:term ->
else_:term ->
ty:term ->
u_ty:universe ->
hyp:var { None? (lookup_bvar g hyp) /\ ~(hyp `Set.mem` (freevars then_ `Set.union` freevars else_)) } ->
eff:T.tot_or_ghost ->
ty_eff:T.tot_or_ghost ->
typing g scrutinee (eff, bool_ty) ->
typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee true_bool)) then_ (eff, ty) ->
typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee false_bool)) else_ (eff, ty) ->
typing g ty (ty_eff, tm_type u_ty) -> //typedness of ty cannot rely on hyp
typing g (mk_if scrutinee then_ else_) (eff, ty)
| T_Match:
g:env ->
sc_u : universe ->
sc_ty : typ ->
sc : term ->
ty_eff:T.tot_or_ghost ->
typing g sc_ty (ty_eff, tm_type sc_u) ->
eff:T.tot_or_ghost ->
typing g sc (eff, sc_ty) ->
branches:list branch ->
ty:comp_typ ->
bnds:list (list R.binding) ->
complet : match_is_complete g sc sc_ty (List.Tot.map fst branches) bnds -> // complete patterns
branches_typing g sc_u sc_ty sc ty branches bnds -> // each branch has proper type
typing g (pack_ln (Tv_Match sc None branches)) ty
and related : env -> term -> relation -> term -> Type0 =
| Rel_refl:
g:env ->
t:term ->
rel:relation ->
related g t rel t
| Rel_sym:
g:env ->
t0:term ->
t1:term ->
related g t0 R_Eq t1 ->
related g t1 R_Eq t0
| Rel_trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
rel:relation ->
related g t0 rel t1 ->
related g t1 rel t2 ->
related g t0 rel t2
| Rel_univ:
g:env ->
u:universe ->
v:universe ->
univ_eq u v ->
related g (tm_type u) R_Eq (tm_type v)
| Rel_beta:
g:env ->
t:typ ->
q:aqualv ->
e:term { ln' e 0 } ->
arg:term { ln arg } ->
related g (R.pack_ln (R.Tv_App (mk_abs t q e) (arg, q)))
R_Eq
(subst_term e [ DT 0 arg ])
| Rel_eq_token:
g:env ->
t0:term ->
t1:term ->
squash (T.equiv_token g t0 t1) ->
related g t0 R_Eq t1
| Rel_subtyping_token:
g:env ->
t0:term ->
t1:term ->
squash (T.subtyping_token g t0 t1) ->
related g t0 R_Sub t1
| Rel_equiv:
g:env ->
t0:term ->
t1:term ->
rel:relation ->
related g t0 R_Eq t1 ->
related g t0 rel t1
| Rel_arrow:
g:env ->
t1:term ->
t2:term ->
q:aqualv ->
c1:comp_typ ->
c2:comp_typ ->
rel:relation ->
x:var{
None? (lookup_bvar g x) /\
~ (x `Set.mem` (freevars_comp_typ c1 `Set.union` freevars_comp_typ c2))
} ->
related g t2 rel t1 ->
related_comp (extend_env g x t2)
(open_comp_typ c1 x)
rel
(open_comp_typ c2 x) ->
related g (mk_arrow_ct t1 q c1) rel (mk_arrow_ct t2 q c2)
| Rel_abs:
g:env ->
t1:term ->
t2:term ->
q:aqualv ->
e1:term ->
e2:term ->
x:var{
None? (lookup_bvar g x) /\ ~ (x `Set.mem` (freevars e1 `Set.union` freevars e2))
} ->
related g t1 R_Eq t2 ->
related (extend_env g x t1)
(subst_term e1 (open_with_var x 0))
R_Eq
(subst_term e2 (open_with_var x 0)) ->
related g (mk_abs t1 q e1) R_Eq (mk_abs t2 q e2)
| Rel_ctxt:
g:env ->
t0:term ->
t1:term ->
ctxt:term_ctxt ->
related g t0 R_Eq t1 ->
related g (apply_term_ctxt ctxt t0) R_Eq (apply_term_ctxt ctxt t1)
and related_comp : env -> comp_typ -> relation -> comp_typ -> Type0 =
| Relc_typ:
g:env ->
t0:term ->
t1:term ->
eff:T.tot_or_ghost ->
rel:relation ->
related g t0 rel t1 ->
related_comp g (eff, t0) rel (eff, t1)
| Relc_total_ghost:
g:env ->
t:term ->
related_comp g (T.E_Total, t) R_Sub (T.E_Ghost, t)
| Relc_ghost_total:
g:env ->
t:term ->
non_informative g t ->
related_comp g (T.E_Ghost, t) R_Sub (T.E_Total, t)
and branches_typing (g:env) (sc_u:universe) (sc_ty:typ) (sc:term) (rty:comp_typ)
: (brs:list branch) -> (bnds : list (list R.binding)) -> Type0
=
(* This judgement only enforces that branch_typing holds for every
element of brs and its respective bnds (which must have the same
length). *)
| BT_Nil :
branches_typing g sc_u sc_ty sc rty [] []
| BT_S :
br : branch ->
bnds : list R.binding ->
pf : branch_typing g sc_u sc_ty sc rty br bnds ->
rest_br : list branch ->
rest_bnds : list (list R.binding) ->
rest : branches_typing g sc_u sc_ty sc rty rest_br rest_bnds ->
branches_typing g sc_u sc_ty sc rty (br :: rest_br) (bnds :: rest_bnds)
and branch_typing (g:env) (sc_u:universe) (sc_ty:typ) (sc:term) (rty:comp_typ)
: (br : branch) -> (bnds : list R.binding) -> Type0
=
| BO :
pat : pattern ->
bnds : list R.binding{bindings_ok_for_pat g bnds pat} ->
hyp_var:var{None? (lookup_bvar (extend_env_l g (refl_bindings_to_bindings bnds)) hyp_var)} ->
body:term ->
_ : squash (Some? (elaborate_pat pat bnds)) ->
typing (extend_env
(extend_env_l g (refl_bindings_to_bindings bnds))
hyp_var (eq2 sc_u sc_ty sc (fst (Some?.v (elaborate_pat pat bnds))))
)
body rty ->
branch_typing g sc_u sc_ty sc rty
(pat, close_term_bs (refl_bindings_to_bindings bnds) body)
bnds
and match_is_complete : env -> term -> typ -> list pattern -> list (list R.binding) -> Type0 =
| MC_Tok :
env:_ ->
sc:_ ->
ty:_ ->
pats:_ ->
bnds:_ ->
squash (T.match_complete_token env sc ty pats bnds) -> match_is_complete env sc ty pats bnds
and sub_typing (g:env) (t1 t2:term) = related g t1 R_Sub t2
and sub_comp (g:env) (c1 c2:comp_typ) = related_comp g c1 R_Sub c2
and equiv (g:env) (t1 t2:term) = related g t1 R_Eq t2
type tot_typing (g:env) (e:term) (t:term) = typing g e (T.E_Total, t)
type ghost_typing (g:env) (e:term) (t:term) = typing g e (T.E_Ghost, t)
val subtyping_token_renaming (g:env)
(bs0:bindings)
(bs1:bindings)
(x:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) x) })
(y:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) y) })
(t:term)
(t0 t1:term)
(d:T.subtyping_token (extend_env_l g (bs1@(x,t)::bs0)) t0 t1)
: T.subtyping_token (extend_env_l g (rename_bindings bs1 x y@(y,t)::bs0))
(rename t0 x y)
(rename t1 x y)
val subtyping_token_weakening (g:env)
(bs0:bindings)
(bs1:bindings)
(x:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) x) })
(t:term)
(t0 t1:term)
(d:T.subtyping_token (extend_env_l g (bs1@bs0)) t0 t1)
: T.subtyping_token (extend_env_l g (bs1@(x,t)::bs0)) t0 t1
let simplify_umax (#g:R.env) (#t:R.term) (#u:R.universe)
(d:typing g t (T.E_Total, tm_type (u_max u u)))
: typing g t (T.E_Total, tm_type u)
= let ue
: univ_eq (u_max u u) u
= UN_MaxLeq u u (UNLEQ_Refl u)
in
let du : related g (tm_type (u_max u u)) R_Eq (tm_type u)
= Rel_univ g (u_max u u) u ue in
let du : related g (tm_type (u_max u u)) R_Sub (tm_type u)
= Rel_equiv _ _ _ _ du in
T_Sub _ _ _ _ d (Relc_typ _ _ _ T.E_Total _ du)
val well_typed_terms_are_ln (g:R.env) (e:R.term) (c:comp_typ) (_:typing g e c)
: Lemma (ensures ln e /\ ln (snd c))
val type_correctness (g:R.env) (e:R.term) (c:comp_typ) (_:typing g e c)
: GTot (u:R.universe & typing g (snd c) (T.E_Total, tm_type u))
val binder_offset_pattern_invariant (p:pattern) (ss:subst)
: Lemma (binder_offset_pattern p == binder_offset_pattern (subst_pattern p ss))
val binder_offset_patterns_invariant (p:list (pattern & bool)) (ss:subst)
: Lemma (binder_offset_patterns p == binder_offset_patterns (subst_patterns p ss))
val open_close_inverse' (i:nat) (t:term { ln' t (i - 1) }) (x:var)
: Lemma
(ensures subst_term
(subst_term t [ ND x i ])
(open_with_var x i)
== t)
val open_close_inverse'_binder (i:nat) (b:binder { ln'_binder b (i - 1) }) (x:var)
: Lemma (ensures subst_binder
(subst_binder b [ ND x i ])
(open_with_var x i)
== b)
val open_close_inverse'_terms (i:nat) (ts:list term { ln'_terms ts (i - 1) }) (x:var)
: Lemma (ensures subst_terms
(subst_terms ts [ ND x i ])
(open_with_var x i)
== ts)
val open_close_inverse'_comp (i:nat) (c:comp { ln'_comp c (i - 1) }) (x:var)
: Lemma
(ensures subst_comp
(subst_comp c [ ND x i ])
(open_with_var x i)
== c)
val open_close_inverse'_args (i:nat)
(ts:list argv { ln'_args ts (i - 1) })
(x:var)
: Lemma
(ensures subst_args
(subst_args ts [ ND x i ])
(open_with_var x i)
== ts)
val open_close_inverse'_patterns (i:nat)
(ps:list (pattern & bool) { ln'_patterns ps (i - 1) })
(x:var)
: Lemma
(ensures subst_patterns
(subst_patterns ps [ ND x i ])
(open_with_var x i)
== ps)
val open_close_inverse'_pattern (i:nat) (p:pattern{ln'_pattern p (i - 1)}) (x:var)
: Lemma
(ensures subst_pattern
(subst_pattern p [ ND x i ])
(open_with_var x i)
== p)
val open_close_inverse'_branch (i:nat) (br:branch{ln'_branch br (i - 1)}) (x:var)
: Lemma
(ensures subst_branch
(subst_branch br [ ND x i ])
(open_with_var x i)
== br)
val open_close_inverse'_branches (i:nat)
(brs:list branch { ln'_branches brs (i - 1) })
(x:var)
: Lemma
(ensures subst_branches
(subst_branches brs [ ND x i ])
(open_with_var x i)
== brs)
val open_close_inverse'_match_returns (i:nat)
(m:match_returns_ascription { ln'_match_returns m (i - 1) })
(x:var)
: Lemma
(ensures subst_match_returns
(subst_match_returns m [ ND x i ])
(open_with_var x i)
== m)
val open_close_inverse (e:R.term { ln e }) (x:var)
: Lemma (open_term (close_term e x) x == e)
val close_open_inverse' (i:nat)
(t:term)
(x:var { ~(x `Set.mem` freevars t) })
: Lemma
(ensures subst_term
(subst_term t (open_with_var x i))
[ ND x i ]
== t)
val close_open_inverse'_comp (i:nat)
(c:comp)
(x:var{ ~(x `Set.mem` freevars_comp c) })
: Lemma
(ensures subst_comp
(subst_comp c (open_with_var x i))
[ ND x i ]
== c)
val close_open_inverse'_args (i:nat) (args:list argv) (x:var{ ~(x `Set.mem` freevars_args args) })
: Lemma
(ensures subst_args
(subst_args args (open_with_var x i))
[ ND x i]
== args)
val close_open_inverse'_binder (i:nat) (b:binder) (x:var{ ~(x `Set.mem` freevars_binder b) })
: Lemma
(ensures subst_binder
(subst_binder b (open_with_var x i))
[ ND x i ]
== b)
val close_open_inverse'_terms (i:nat) (ts:list term) (x:var{ ~(x `Set.mem` freevars_terms ts) })
: Lemma
(ensures subst_terms
(subst_terms ts (open_with_var x i))
[ ND x i ]
== ts)
val close_open_inverse'_branches (i:nat) (brs:list branch)
(x:var{ ~(x `Set.mem` freevars_branches brs) })
: Lemma
(ensures subst_branches
(subst_branches brs (open_with_var x i))
[ ND x i ]
== brs)
val close_open_inverse'_branch (i:nat)
(br:branch)
(x:var{ ~(x `Set.mem` freevars_branch br) })
: Lemma
(ensures subst_branch
(subst_branch br (open_with_var x i))
[ ND x i ]
== br)
val close_open_inverse'_pattern (i:nat)
(p:pattern)
(x:var{ ~(x `Set.mem` freevars_pattern p) })
: Lemma
(ensures subst_pattern
(subst_pattern p (open_with_var x i))
[ ND x i ]
== p)
val close_open_inverse'_patterns (i:nat)
(ps:list (pattern & bool))
(x:var {~ (x `Set.mem` freevars_patterns ps) })
: Lemma
(ensures subst_patterns
(subst_patterns ps (open_with_var x i))
[ ND x i ]
== ps)
val close_open_inverse'_match_returns (i:nat) (m:match_returns_ascription)
(x:var{ ~(x `Set.mem` freevars_match_returns m) })
: Lemma
(ensures subst_match_returns
(subst_match_returns m (open_with_var x i))
[ ND x i ]
== m)
val close_open_inverse (e:R.term) (x:var {~ (x `Set.mem` freevars e) })
: Lemma (close_term (open_term e x) x == e)
//
// fst has corresponding lemmas for other syntax classes
//
val close_with_not_free_var (t:R.term) (x:var) (i:nat)
: Lemma
(requires ~ (Set.mem x (freevars t)))
(ensures subst_term t [ ND x i ] == t)
// this also requires x to be not in freevars e1 `Set.union` freevars e2
val equiv_arrow (#g:R.env) (#e1 #e2:R.term) (ty:R.typ) (q:R.aqualv)
(x:var { None? (lookup_bvar g x) })
(eq:equiv (extend_env g x ty)
(subst_term e1 (open_with_var x 0))
(subst_term e2 (open_with_var x 0)))
: equiv g (mk_arrow ty q e1)
(mk_arrow ty q e2)
// the proof for this requires e1 and e2 to be ln
val equiv_abs_close (#g:R.env) (#e1 #e2:R.term) (ty:R.typ) (q:R.aqualv)
(x:var{None? (lookup_bvar g x)})
(eq:equiv (extend_env g x ty) e1 e2)
: equiv g (mk_abs ty q (subst_term e1 [ ND x 0 ]))
(mk_abs ty q (subst_term e2 [ ND x 0 ]))
val open_with_gt_ln (e:term) (i:nat) (t:term) (j:nat)
: Lemma
(requires ln' e i /\ i < j)
(ensures subst_term e [ DT j t ] == e)
[SMTPat (ln' e i); SMTPat (subst_term e [ DT j t ])]
//
// Type of the top-level tactic that would splice-in the definitions
//
let fstar_env_fvs (g:R.env) =
lookup_fvar g unit_fv == Some (tm_type u_zero) /\
lookup_fvar g bool_fv == Some (tm_type u_zero) /\
lookup_fvar g b2t_fv == Some b2t_ty
type fstar_env = g:R.env{fstar_env_fvs g}
type fstar_top_env = g:fstar_env {
forall x. None? (lookup_bvar g x )
}
//
// This doesn't allow for universe polymorphic definitions
//
// May be we can change it to:
//
// g:fstar_top_env -> T.tac ((us, e, t):(univ_names & term & typ){typing (push g us) e t})
//
noeq
type sigelt_typing : env -> sigelt -> Type0 =
| ST_Let :
g : env ->
fv : R.fv ->
ty : R.typ ->
tm : R.term ->
squash (typing g tm (T.E_Total, ty)) ->
sigelt_typing g (pack_sigelt (Sg_Let false [pack_lb ({ lb_fv = fv; lb_us = []; lb_typ = ty; lb_def = tm })]))
| ST_Let_Opaque :
g : env ->
fv : R.fv ->
ty : R.typ ->
(* no tm: only a proof of existence *)
squash (exists (tm:R.term). typing g tm (T.E_Total, ty)) ->
sigelt_typing g (pack_sigelt (Sg_Let false [pack_lb ({ lb_fv = fv; lb_us = []; lb_typ = ty; lb_def = (`_) })]))
(**
* The type of the top-level tactic that would splice-in the definitions.
* It returns a list of well typed definitions, via the judgment above.
*
* Each definition can have a 'blob' attached with a given name.
* The blob can be used later, e.g., during extraction, and passed back to the
* extension to perform additional processing.
*)
(*
* It returns either:
* - Some tm, blob, typ, with a proof that `typing g tm typ`
* - None, blob, typ), with a proof that `exists tm. typing g tm typ`
* The blob itself is optional and can store some additional metadata that
* constructed by the tactic. If present, it will be stored in the
* sigmeta_extension_data field of the enclosing sigelt.
*
*)
let blob = string & R.term
(* If checked is true, this sigelt is properly typed for the environment. If not,
we don't know and let F* re-typecheck the sigelt. *) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sigelt_for : g: FStar.Reflection.Types.env -> Type0 | [] | FStar.Reflection.Typing.sigelt_for | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | g: FStar.Reflection.Types.env -> Type0 | {
"end_col": 3,
"end_line": 1801,
"start_col": 2,
"start_line": 1797
} |
|
Prims.Tot | val b2t_ty:R.term | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero))) | val b2t_ty:R.term
let b2t_ty:R.term = | false | null | false | R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero))) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_Arrow",
"FStar.Reflection.Typing.mk_binder",
"FStar.Sealed.seal",
"Prims.string",
"FStar.Reflection.Typing.bool_ty",
"FStar.Reflection.V2.Data.Q_Explicit",
"FStar.Reflection.Typing.mk_total",
"FStar.Reflection.Typing.tm_type",
"FStar.Reflection.Typing.u_zero"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"] | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val b2t_ty:R.term | [] | FStar.Reflection.Typing.b2t_ty | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Reflection.Types.term | {
"end_col": 114,
"end_line": 559,
"start_col": 22,
"start_line": 559
} |
Prims.Tot | val freevars_opt (#a: Type0) (o: option a) (f: (x: a{x << o} -> FStar.Set.set var))
: FStar.Set.set var | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_ | val freevars_opt (#a: Type0) (o: option a) (f: (x: a{x << o} -> FStar.Set.set var))
: FStar.Set.set var
let rec freevars_opt (#a: Type0) (o: option a) (f: (x: a{x << o} -> FStar.Set.set var))
: FStar.Set.set var = | false | null | false | match o with
| None -> Set.empty
| Some x -> f x | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Pervasives.Native.option",
"Prims.precedes",
"FStar.Set.set",
"FStar.Reflection.V2.Data.var",
"FStar.Set.empty"
] | [
"freevars",
"freevars_opt",
"freevars_comp",
"freevars_args",
"freevars_terms",
"freevars_binder",
"freevars_pattern",
"freevars_patterns",
"freevars_branch",
"freevars_branches",
"freevars_match_returns"
] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var)) | false | false | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val freevars_opt (#a: Type0) (o: option a) (f: (x: a{x << o} -> FStar.Set.set var))
: FStar.Set.set var | [
"mutual recursion"
] | FStar.Reflection.Typing.freevars_opt | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
o: FStar.Pervasives.Native.option a ->
f: (x: a{x << o} -> FStar.Set.set FStar.Reflection.V2.Data.var)
-> FStar.Set.set FStar.Reflection.V2.Data.var | {
"end_col": 19,
"end_line": 620,
"start_col": 4,
"start_line": 618
} |
Prims.Tot | val apply_term_ctxt (e: term_ctxt) (t: term) : Tot term (decreases e) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q)) | val apply_term_ctxt (e: term_ctxt) (t: term) : Tot term (decreases e)
let rec apply_term_ctxt (e: term_ctxt) (t: term) : Tot term (decreases e) = | false | null | false | match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q)) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total",
""
] | [
"FStar.Reflection.Typing.term_ctxt",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Data.argv",
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_App",
"FStar.Reflection.Typing.apply_term_ctxt",
"FStar.Reflection.V2.Data.aqualv",
"FStar.Pervasives.Native.Mktuple2"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val apply_term_ctxt (e: term_ctxt) (t: term) : Tot term (decreases e) | [
"recursion"
] | FStar.Reflection.Typing.apply_term_ctxt | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | e: FStar.Reflection.Typing.term_ctxt -> t: FStar.Reflection.Types.term
-> Prims.Tot FStar.Reflection.Types.term | {
"end_col": 71,
"end_line": 902,
"start_col": 2,
"start_line": 899
} |
Prims.Tot | val is_non_informative_name (l: name) : bool | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"] | val is_non_informative_name (l: name) : bool
let is_non_informative_name (l: name) : bool = | false | null | false | l = R.unit_lid || l = R.squash_qn || l = ["FStar"; "Ghost"; "erased"] | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.name",
"Prims.op_BarBar",
"Prims.op_Equality",
"Prims.list",
"Prims.string",
"FStar.Reflection.Const.unit_lid",
"FStar.Reflection.Const.squash_qn",
"Prims.Cons",
"Prims.Nil",
"Prims.bool"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
// | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_non_informative_name (l: name) : bool | [] | FStar.Reflection.Typing.is_non_informative_name | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: FStar.Reflection.Types.name -> Prims.bool | {
"end_col": 34,
"end_line": 1033,
"start_col": 2,
"start_line": 1031
} |
Prims.Tot | val mk_comp (c: comp_typ) : R.comp | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c) | val mk_comp (c: comp_typ) : R.comp
let mk_comp (c: comp_typ) : R.comp = | false | null | false | match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Typing.comp_typ",
"FStar.Pervasives.Native.fst",
"FStar.Stubs.TypeChecker.Core.tot_or_ghost",
"FStar.Reflection.Types.typ",
"FStar.Reflection.Typing.mk_total",
"FStar.Pervasives.Native.snd",
"FStar.Reflection.Typing.mk_ghost",
"FStar.Reflection.Types.comp"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_comp (c: comp_typ) : R.comp | [] | FStar.Reflection.Typing.mk_comp | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | c: FStar.Reflection.Typing.comp_typ -> FStar.Reflection.Types.comp | {
"end_col": 33,
"end_line": 1008,
"start_col": 2,
"start_line": 1006
} |
Prims.Tot | val bindings_to_refl_bindings (bs: list binding) : list R.binding | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bindings_to_refl_bindings (bs : list binding) : list R.binding =
L.map (fun (v, ty) -> {uniq=v; sort=ty; ppname = pp_name_default}) bs | val bindings_to_refl_bindings (bs: list binding) : list R.binding
let bindings_to_refl_bindings (bs: list binding) : list R.binding = | false | null | false | L.map (fun (v, ty) -> { uniq = v; sort = ty; ppname = pp_name_default }) bs | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"Prims.list",
"FStar.Reflection.Typing.binding",
"FStar.List.Tot.Base.map",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"FStar.Reflection.Types.typ",
"FStar.Reflection.V2.Data.binding",
"FStar.Reflection.V2.Data.Mkbinding",
"FStar.Reflection.Typing.pp_name_default"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"]
let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f)
let rec __close_term_vs (i:nat) (vs : list var) (t : term) : Tot term (decreases vs) =
match vs with
| [] -> t
| v::vs ->
subst_term (__close_term_vs (i+1) vs t) [ND v i]
let close_term_vs (vs : list var) (t : term) : term =
__close_term_vs 0 vs t
let close_term_bs (bs : list binding) (t : term) : term =
close_term_vs (List.Tot.map fst bs) t | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bindings_to_refl_bindings (bs: list binding) : list R.binding | [] | FStar.Reflection.Typing.bindings_to_refl_bindings | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bs: Prims.list FStar.Reflection.Typing.binding -> Prims.list FStar.Reflection.V2.Data.binding | {
"end_col": 71,
"end_line": 1051,
"start_col": 2,
"start_line": 1051
} |
FStar.Tactics.Effect.Tac | val mk_checked_let (g: R.env) (nm: string) (tm: R.term) (ty: R.typ{typing g tm (T.E_Total, ty)})
: T.Tac (sigelt_for g) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_checked_let (g:R.env) (nm:string) (tm:R.term) (ty:R.typ{typing g tm (T.E_Total, ty)}) : T.Tac (sigelt_for g) =
let fv = pack_fv (T.cur_module () @ [nm]) in
let lb = R.pack_lb ({ lb_fv = fv; lb_us = []; lb_typ = ty; lb_def = tm }) in
let se = R.pack_sigelt (R.Sg_Let false [lb]) in
let pf : sigelt_typing g se =
ST_Let g fv ty tm ()
in
( true, se, None ) | val mk_checked_let (g: R.env) (nm: string) (tm: R.term) (ty: R.typ{typing g tm (T.E_Total, ty)})
: T.Tac (sigelt_for g)
let mk_checked_let (g: R.env) (nm: string) (tm: R.term) (ty: R.typ{typing g tm (T.E_Total, ty)})
: T.Tac (sigelt_for g) = | true | null | false | let fv = pack_fv (T.cur_module () @ [nm]) in
let lb = R.pack_lb ({ lb_fv = fv; lb_us = []; lb_typ = ty; lb_def = tm }) in
let se = R.pack_sigelt (R.Sg_Let false [lb]) in
let pf:sigelt_typing g se = ST_Let g fv ty tm () in
(true, se, None) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [] | [
"FStar.Reflection.Types.env",
"Prims.string",
"FStar.Reflection.Types.term",
"FStar.Reflection.Types.typ",
"FStar.Reflection.Typing.typing",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Stubs.TypeChecker.Core.tot_or_ghost",
"FStar.Stubs.TypeChecker.Core.E_Total",
"FStar.Pervasives.Native.Mktuple3",
"Prims.bool",
"FStar.Reflection.Types.sigelt",
"FStar.Pervasives.Native.option",
"FStar.Reflection.Typing.blob",
"FStar.Pervasives.Native.None",
"FStar.Reflection.Typing.sigelt_typing",
"FStar.Reflection.Typing.ST_Let",
"FStar.Reflection.V2.Builtins.pack_sigelt",
"FStar.Reflection.V2.Data.Sg_Let",
"Prims.Cons",
"FStar.Reflection.Types.letbinding",
"Prims.Nil",
"FStar.Reflection.V2.Builtins.pack_lb",
"FStar.Reflection.V2.Data.Mklb_view",
"FStar.Reflection.Types.univ_name",
"FStar.Reflection.Typing.sigelt_for",
"FStar.Reflection.Types.fv",
"FStar.Reflection.V2.Builtins.pack_fv",
"FStar.Reflection.Types.name",
"FStar.List.Tot.Base.op_At",
"Prims.list",
"FStar.Tactics.V2.Derived.cur_module"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"]
let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f)
let rec __close_term_vs (i:nat) (vs : list var) (t : term) : Tot term (decreases vs) =
match vs with
| [] -> t
| v::vs ->
subst_term (__close_term_vs (i+1) vs t) [ND v i]
let close_term_vs (vs : list var) (t : term) : term =
__close_term_vs 0 vs t
let close_term_bs (bs : list binding) (t : term) : term =
close_term_vs (List.Tot.map fst bs) t
let bindings_to_refl_bindings (bs : list binding) : list R.binding =
L.map (fun (v, ty) -> {uniq=v; sort=ty; ppname = pp_name_default}) bs
let refl_bindings_to_bindings (bs : list R.binding) : list binding =
L.map (fun b -> b.uniq, b.sort) bs
[@@ no_auto_projectors]
noeq
type non_informative : env -> term -> Type0 =
| Non_informative_type:
g:env ->
u:universe ->
non_informative g (pack_ln (Tv_Type u))
| Non_informative_fv:
g:env ->
x:fv{is_non_informative_fv x} ->
non_informative g (pack_ln (Tv_FVar x))
| Non_informative_uinst:
g:env ->
x:fv{is_non_informative_fv x} ->
us:list universe ->
non_informative g (pack_ln (Tv_UInst x us))
| Non_informative_app:
g:env ->
t:term ->
arg:argv ->
non_informative g t ->
non_informative g (pack_ln (Tv_App t arg))
| Non_informative_total_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g t1 ->
non_informative g (mk_arrow_ct t0 q (T.E_Total, t1))
| Non_informative_ghost_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g (mk_arrow_ct t0 q (T.E_Ghost, t1))
| Non_informative_token:
g:env ->
t:typ ->
squash (T.non_informative_token g t) ->
non_informative g t
val bindings_ok_for_pat : env -> list R.binding -> pattern -> Type0
val bindings_ok_pat_constant :
g:env -> c:R.vconst -> Lemma (bindings_ok_for_pat g [] (Pat_Constant c))
let bindings_ok_for_branch (g:env) (bs : list R.binding) (br : branch) : Type0 =
bindings_ok_for_pat g bs (fst br)
let bindings_ok_for_branch_N (g:env) (bss : list (list R.binding)) (brs : list branch) =
zip2prop (bindings_ok_for_branch g) bss brs
let binding_to_namedv (b:R.binding) : Tot namedv =
pack_namedv {
RD.uniq = b.uniq;
RD.sort = seal b.sort;
RD.ppname = b.ppname;
}
(* Elaborates the p pattern into a term, using the bs bindings for the
pattern variables. The resulting term is properly scoped only on an
environment which contains all of bs. See for instance the branch_typing
judg. Returns an option, since this can fail if e.g. there are not
enough bindings, and returns the list of unused binders as well, which
should be empty if the list of binding was indeed ok. *)
let rec elaborate_pat (p : pattern) (bs : list R.binding) : Tot (option (term & list R.binding)) (decreases p) =
match p, bs with
| Pat_Constant c, _ -> Some (pack_ln (Tv_Const c), bs)
| Pat_Cons fv univs subpats, bs ->
let head = pack_ln (Tv_FVar fv) in
fold_left_dec
(Some (head, bs))
subpats
(fun st pi ->
let (p,i) = pi in
match st with | None -> None | Some (head, bs) ->
match elaborate_pat p bs with | None -> None | Some (t, bs') -> Some (pack_ln (Tv_App head (t, (if i then Q_Implicit else Q_Explicit))), bs'))
| Pat_Var _ _, b::bs ->
Some (pack_ln (Tv_Var (binding_to_namedv b)), bs)
| Pat_Dot_Term (Some t), _ -> Some (t, bs)
| Pat_Dot_Term None, _ -> None
| _ -> None
[@@ no_auto_projectors]
noeq
type typing : env -> term -> comp_typ -> Type0 =
| T_Token :
g:env ->
e:term ->
c:comp_typ ->
squash (T.typing_token g e c) ->
typing g e c
| T_Var :
g:env ->
x:namedv { Some? (lookup_bvar g (namedv_uniq x)) } ->
typing g (pack_ln (Tv_Var x)) (T.E_Total, Some?.v (lookup_bvar g (namedv_uniq x)))
| T_FVar :
g:env ->
x:fv { Some? (lookup_fvar g x) } ->
typing g (pack_ln (Tv_FVar x)) (T.E_Total, Some?.v (lookup_fvar g x))
| T_UInst :
g:env ->
x:fv ->
us:list universe { Some? (lookup_fvar_uinst g x us) } ->
typing g (pack_ln (Tv_UInst x us)) (T.E_Total, Some?.v (lookup_fvar_uinst g x us))
| T_Const:
g:env ->
v:vconst ->
t:term ->
constant_typing v t ->
typing g (constant_as_term v) (T.E_Total, t)
| T_Abs :
g:env ->
x:var { None? (lookup_bvar g x) } ->
ty:term ->
body:term { ~(x `Set.mem` freevars body) } ->
body_c:comp_typ ->
u:universe ->
pp_name:pp_name_t ->
q:aqualv ->
ty_eff:T.tot_or_ghost ->
typing g ty (ty_eff, tm_type u) ->
typing (extend_env g x ty) (open_term body x) body_c ->
typing g (pack_ln (Tv_Abs (mk_binder pp_name ty q) body))
(T.E_Total,
pack_ln (Tv_Arrow (mk_binder pp_name ty q)
(mk_comp (close_comp_typ body_c x))))
| T_App :
g:env ->
e1:term ->
e2:term ->
x:binder ->
t:term ->
eff:T.tot_or_ghost ->
typing g e1 (eff, pack_ln (Tv_Arrow x (mk_comp (eff, t)))) ->
typing g e2 (eff, binder_sort x) ->
typing g (pack_ln (Tv_App e1 (e2, binder_qual x)))
(eff, open_with t e2)
| T_Let:
g:env ->
x:var { None? (lookup_bvar g x) } ->
e1:term ->
t1:typ ->
e2:term ->
t2:typ ->
eff:T.tot_or_ghost ->
pp_name:pp_name_t ->
typing g e1 (eff, t1) ->
typing (extend_env g x t1) (open_term e2 x) (eff, t2) ->
typing g (mk_let pp_name e1 t1 e2) (eff, open_with (close_term t2 x) e1)
| T_Arrow:
g:env ->
x:var { None? (lookup_bvar g x) } ->
t1:term ->
t2:term { ~(x `Set.mem` freevars t2) } ->
u1:universe ->
u2:universe ->
pp_name:pp_name_t ->
q:aqualv ->
eff:T.tot_or_ghost ->
t1_eff:T.tot_or_ghost ->
t2_eff:T.tot_or_ghost ->
typing g t1 (t1_eff, tm_type u1) ->
typing (extend_env g x t1) (open_term t2 x) (t2_eff, tm_type u2) ->
typing g (pack_ln (Tv_Arrow (mk_binder pp_name t1 q) (mk_comp (eff, t2))))
(T.E_Total, tm_type (u_max u1 u2))
| T_Refine:
g:env ->
x:var { None? (lookup_bvar g x) } ->
t:term ->
e:term { ~(x `Set.mem` freevars e) } ->
u1:universe ->
u2:universe ->
t_eff:T.tot_or_ghost ->
e_eff:T.tot_or_ghost ->
typing g t (t_eff, tm_type u1) ->
typing (extend_env g x t) (open_term e x) (e_eff, tm_type u2) ->
typing g (pack_ln (Tv_Refine (mk_simple_binder pp_name_default t) e)) (T.E_Total, tm_type u1)
| T_PropIrrelevance:
g:env ->
e:term ->
t:term ->
e_eff:T.tot_or_ghost ->
t_eff:T.tot_or_ghost ->
typing g e (e_eff, t) ->
typing g t (t_eff, tm_prop) ->
typing g (`()) (T.E_Total, t)
| T_Sub:
g:env ->
e:term ->
c:comp_typ ->
c':comp_typ ->
typing g e c ->
sub_comp g c c' ->
typing g e c'
| T_If:
g:env ->
scrutinee:term ->
then_:term ->
else_:term ->
ty:term ->
u_ty:universe ->
hyp:var { None? (lookup_bvar g hyp) /\ ~(hyp `Set.mem` (freevars then_ `Set.union` freevars else_)) } ->
eff:T.tot_or_ghost ->
ty_eff:T.tot_or_ghost ->
typing g scrutinee (eff, bool_ty) ->
typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee true_bool)) then_ (eff, ty) ->
typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee false_bool)) else_ (eff, ty) ->
typing g ty (ty_eff, tm_type u_ty) -> //typedness of ty cannot rely on hyp
typing g (mk_if scrutinee then_ else_) (eff, ty)
| T_Match:
g:env ->
sc_u : universe ->
sc_ty : typ ->
sc : term ->
ty_eff:T.tot_or_ghost ->
typing g sc_ty (ty_eff, tm_type sc_u) ->
eff:T.tot_or_ghost ->
typing g sc (eff, sc_ty) ->
branches:list branch ->
ty:comp_typ ->
bnds:list (list R.binding) ->
complet : match_is_complete g sc sc_ty (List.Tot.map fst branches) bnds -> // complete patterns
branches_typing g sc_u sc_ty sc ty branches bnds -> // each branch has proper type
typing g (pack_ln (Tv_Match sc None branches)) ty
and related : env -> term -> relation -> term -> Type0 =
| Rel_refl:
g:env ->
t:term ->
rel:relation ->
related g t rel t
| Rel_sym:
g:env ->
t0:term ->
t1:term ->
related g t0 R_Eq t1 ->
related g t1 R_Eq t0
| Rel_trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
rel:relation ->
related g t0 rel t1 ->
related g t1 rel t2 ->
related g t0 rel t2
| Rel_univ:
g:env ->
u:universe ->
v:universe ->
univ_eq u v ->
related g (tm_type u) R_Eq (tm_type v)
| Rel_beta:
g:env ->
t:typ ->
q:aqualv ->
e:term { ln' e 0 } ->
arg:term { ln arg } ->
related g (R.pack_ln (R.Tv_App (mk_abs t q e) (arg, q)))
R_Eq
(subst_term e [ DT 0 arg ])
| Rel_eq_token:
g:env ->
t0:term ->
t1:term ->
squash (T.equiv_token g t0 t1) ->
related g t0 R_Eq t1
| Rel_subtyping_token:
g:env ->
t0:term ->
t1:term ->
squash (T.subtyping_token g t0 t1) ->
related g t0 R_Sub t1
| Rel_equiv:
g:env ->
t0:term ->
t1:term ->
rel:relation ->
related g t0 R_Eq t1 ->
related g t0 rel t1
| Rel_arrow:
g:env ->
t1:term ->
t2:term ->
q:aqualv ->
c1:comp_typ ->
c2:comp_typ ->
rel:relation ->
x:var{
None? (lookup_bvar g x) /\
~ (x `Set.mem` (freevars_comp_typ c1 `Set.union` freevars_comp_typ c2))
} ->
related g t2 rel t1 ->
related_comp (extend_env g x t2)
(open_comp_typ c1 x)
rel
(open_comp_typ c2 x) ->
related g (mk_arrow_ct t1 q c1) rel (mk_arrow_ct t2 q c2)
| Rel_abs:
g:env ->
t1:term ->
t2:term ->
q:aqualv ->
e1:term ->
e2:term ->
x:var{
None? (lookup_bvar g x) /\ ~ (x `Set.mem` (freevars e1 `Set.union` freevars e2))
} ->
related g t1 R_Eq t2 ->
related (extend_env g x t1)
(subst_term e1 (open_with_var x 0))
R_Eq
(subst_term e2 (open_with_var x 0)) ->
related g (mk_abs t1 q e1) R_Eq (mk_abs t2 q e2)
| Rel_ctxt:
g:env ->
t0:term ->
t1:term ->
ctxt:term_ctxt ->
related g t0 R_Eq t1 ->
related g (apply_term_ctxt ctxt t0) R_Eq (apply_term_ctxt ctxt t1)
and related_comp : env -> comp_typ -> relation -> comp_typ -> Type0 =
| Relc_typ:
g:env ->
t0:term ->
t1:term ->
eff:T.tot_or_ghost ->
rel:relation ->
related g t0 rel t1 ->
related_comp g (eff, t0) rel (eff, t1)
| Relc_total_ghost:
g:env ->
t:term ->
related_comp g (T.E_Total, t) R_Sub (T.E_Ghost, t)
| Relc_ghost_total:
g:env ->
t:term ->
non_informative g t ->
related_comp g (T.E_Ghost, t) R_Sub (T.E_Total, t)
and branches_typing (g:env) (sc_u:universe) (sc_ty:typ) (sc:term) (rty:comp_typ)
: (brs:list branch) -> (bnds : list (list R.binding)) -> Type0
=
(* This judgement only enforces that branch_typing holds for every
element of brs and its respective bnds (which must have the same
length). *)
| BT_Nil :
branches_typing g sc_u sc_ty sc rty [] []
| BT_S :
br : branch ->
bnds : list R.binding ->
pf : branch_typing g sc_u sc_ty sc rty br bnds ->
rest_br : list branch ->
rest_bnds : list (list R.binding) ->
rest : branches_typing g sc_u sc_ty sc rty rest_br rest_bnds ->
branches_typing g sc_u sc_ty sc rty (br :: rest_br) (bnds :: rest_bnds)
and branch_typing (g:env) (sc_u:universe) (sc_ty:typ) (sc:term) (rty:comp_typ)
: (br : branch) -> (bnds : list R.binding) -> Type0
=
| BO :
pat : pattern ->
bnds : list R.binding{bindings_ok_for_pat g bnds pat} ->
hyp_var:var{None? (lookup_bvar (extend_env_l g (refl_bindings_to_bindings bnds)) hyp_var)} ->
body:term ->
_ : squash (Some? (elaborate_pat pat bnds)) ->
typing (extend_env
(extend_env_l g (refl_bindings_to_bindings bnds))
hyp_var (eq2 sc_u sc_ty sc (fst (Some?.v (elaborate_pat pat bnds))))
)
body rty ->
branch_typing g sc_u sc_ty sc rty
(pat, close_term_bs (refl_bindings_to_bindings bnds) body)
bnds
and match_is_complete : env -> term -> typ -> list pattern -> list (list R.binding) -> Type0 =
| MC_Tok :
env:_ ->
sc:_ ->
ty:_ ->
pats:_ ->
bnds:_ ->
squash (T.match_complete_token env sc ty pats bnds) -> match_is_complete env sc ty pats bnds
and sub_typing (g:env) (t1 t2:term) = related g t1 R_Sub t2
and sub_comp (g:env) (c1 c2:comp_typ) = related_comp g c1 R_Sub c2
and equiv (g:env) (t1 t2:term) = related g t1 R_Eq t2
type tot_typing (g:env) (e:term) (t:term) = typing g e (T.E_Total, t)
type ghost_typing (g:env) (e:term) (t:term) = typing g e (T.E_Ghost, t)
val subtyping_token_renaming (g:env)
(bs0:bindings)
(bs1:bindings)
(x:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) x) })
(y:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) y) })
(t:term)
(t0 t1:term)
(d:T.subtyping_token (extend_env_l g (bs1@(x,t)::bs0)) t0 t1)
: T.subtyping_token (extend_env_l g (rename_bindings bs1 x y@(y,t)::bs0))
(rename t0 x y)
(rename t1 x y)
val subtyping_token_weakening (g:env)
(bs0:bindings)
(bs1:bindings)
(x:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) x) })
(t:term)
(t0 t1:term)
(d:T.subtyping_token (extend_env_l g (bs1@bs0)) t0 t1)
: T.subtyping_token (extend_env_l g (bs1@(x,t)::bs0)) t0 t1
let simplify_umax (#g:R.env) (#t:R.term) (#u:R.universe)
(d:typing g t (T.E_Total, tm_type (u_max u u)))
: typing g t (T.E_Total, tm_type u)
= let ue
: univ_eq (u_max u u) u
= UN_MaxLeq u u (UNLEQ_Refl u)
in
let du : related g (tm_type (u_max u u)) R_Eq (tm_type u)
= Rel_univ g (u_max u u) u ue in
let du : related g (tm_type (u_max u u)) R_Sub (tm_type u)
= Rel_equiv _ _ _ _ du in
T_Sub _ _ _ _ d (Relc_typ _ _ _ T.E_Total _ du)
val well_typed_terms_are_ln (g:R.env) (e:R.term) (c:comp_typ) (_:typing g e c)
: Lemma (ensures ln e /\ ln (snd c))
val type_correctness (g:R.env) (e:R.term) (c:comp_typ) (_:typing g e c)
: GTot (u:R.universe & typing g (snd c) (T.E_Total, tm_type u))
val binder_offset_pattern_invariant (p:pattern) (ss:subst)
: Lemma (binder_offset_pattern p == binder_offset_pattern (subst_pattern p ss))
val binder_offset_patterns_invariant (p:list (pattern & bool)) (ss:subst)
: Lemma (binder_offset_patterns p == binder_offset_patterns (subst_patterns p ss))
val open_close_inverse' (i:nat) (t:term { ln' t (i - 1) }) (x:var)
: Lemma
(ensures subst_term
(subst_term t [ ND x i ])
(open_with_var x i)
== t)
val open_close_inverse'_binder (i:nat) (b:binder { ln'_binder b (i - 1) }) (x:var)
: Lemma (ensures subst_binder
(subst_binder b [ ND x i ])
(open_with_var x i)
== b)
val open_close_inverse'_terms (i:nat) (ts:list term { ln'_terms ts (i - 1) }) (x:var)
: Lemma (ensures subst_terms
(subst_terms ts [ ND x i ])
(open_with_var x i)
== ts)
val open_close_inverse'_comp (i:nat) (c:comp { ln'_comp c (i - 1) }) (x:var)
: Lemma
(ensures subst_comp
(subst_comp c [ ND x i ])
(open_with_var x i)
== c)
val open_close_inverse'_args (i:nat)
(ts:list argv { ln'_args ts (i - 1) })
(x:var)
: Lemma
(ensures subst_args
(subst_args ts [ ND x i ])
(open_with_var x i)
== ts)
val open_close_inverse'_patterns (i:nat)
(ps:list (pattern & bool) { ln'_patterns ps (i - 1) })
(x:var)
: Lemma
(ensures subst_patterns
(subst_patterns ps [ ND x i ])
(open_with_var x i)
== ps)
val open_close_inverse'_pattern (i:nat) (p:pattern{ln'_pattern p (i - 1)}) (x:var)
: Lemma
(ensures subst_pattern
(subst_pattern p [ ND x i ])
(open_with_var x i)
== p)
val open_close_inverse'_branch (i:nat) (br:branch{ln'_branch br (i - 1)}) (x:var)
: Lemma
(ensures subst_branch
(subst_branch br [ ND x i ])
(open_with_var x i)
== br)
val open_close_inverse'_branches (i:nat)
(brs:list branch { ln'_branches brs (i - 1) })
(x:var)
: Lemma
(ensures subst_branches
(subst_branches brs [ ND x i ])
(open_with_var x i)
== brs)
val open_close_inverse'_match_returns (i:nat)
(m:match_returns_ascription { ln'_match_returns m (i - 1) })
(x:var)
: Lemma
(ensures subst_match_returns
(subst_match_returns m [ ND x i ])
(open_with_var x i)
== m)
val open_close_inverse (e:R.term { ln e }) (x:var)
: Lemma (open_term (close_term e x) x == e)
val close_open_inverse' (i:nat)
(t:term)
(x:var { ~(x `Set.mem` freevars t) })
: Lemma
(ensures subst_term
(subst_term t (open_with_var x i))
[ ND x i ]
== t)
val close_open_inverse'_comp (i:nat)
(c:comp)
(x:var{ ~(x `Set.mem` freevars_comp c) })
: Lemma
(ensures subst_comp
(subst_comp c (open_with_var x i))
[ ND x i ]
== c)
val close_open_inverse'_args (i:nat) (args:list argv) (x:var{ ~(x `Set.mem` freevars_args args) })
: Lemma
(ensures subst_args
(subst_args args (open_with_var x i))
[ ND x i]
== args)
val close_open_inverse'_binder (i:nat) (b:binder) (x:var{ ~(x `Set.mem` freevars_binder b) })
: Lemma
(ensures subst_binder
(subst_binder b (open_with_var x i))
[ ND x i ]
== b)
val close_open_inverse'_terms (i:nat) (ts:list term) (x:var{ ~(x `Set.mem` freevars_terms ts) })
: Lemma
(ensures subst_terms
(subst_terms ts (open_with_var x i))
[ ND x i ]
== ts)
val close_open_inverse'_branches (i:nat) (brs:list branch)
(x:var{ ~(x `Set.mem` freevars_branches brs) })
: Lemma
(ensures subst_branches
(subst_branches brs (open_with_var x i))
[ ND x i ]
== brs)
val close_open_inverse'_branch (i:nat)
(br:branch)
(x:var{ ~(x `Set.mem` freevars_branch br) })
: Lemma
(ensures subst_branch
(subst_branch br (open_with_var x i))
[ ND x i ]
== br)
val close_open_inverse'_pattern (i:nat)
(p:pattern)
(x:var{ ~(x `Set.mem` freevars_pattern p) })
: Lemma
(ensures subst_pattern
(subst_pattern p (open_with_var x i))
[ ND x i ]
== p)
val close_open_inverse'_patterns (i:nat)
(ps:list (pattern & bool))
(x:var {~ (x `Set.mem` freevars_patterns ps) })
: Lemma
(ensures subst_patterns
(subst_patterns ps (open_with_var x i))
[ ND x i ]
== ps)
val close_open_inverse'_match_returns (i:nat) (m:match_returns_ascription)
(x:var{ ~(x `Set.mem` freevars_match_returns m) })
: Lemma
(ensures subst_match_returns
(subst_match_returns m (open_with_var x i))
[ ND x i ]
== m)
val close_open_inverse (e:R.term) (x:var {~ (x `Set.mem` freevars e) })
: Lemma (close_term (open_term e x) x == e)
//
// fst has corresponding lemmas for other syntax classes
//
val close_with_not_free_var (t:R.term) (x:var) (i:nat)
: Lemma
(requires ~ (Set.mem x (freevars t)))
(ensures subst_term t [ ND x i ] == t)
// this also requires x to be not in freevars e1 `Set.union` freevars e2
val equiv_arrow (#g:R.env) (#e1 #e2:R.term) (ty:R.typ) (q:R.aqualv)
(x:var { None? (lookup_bvar g x) })
(eq:equiv (extend_env g x ty)
(subst_term e1 (open_with_var x 0))
(subst_term e2 (open_with_var x 0)))
: equiv g (mk_arrow ty q e1)
(mk_arrow ty q e2)
// the proof for this requires e1 and e2 to be ln
val equiv_abs_close (#g:R.env) (#e1 #e2:R.term) (ty:R.typ) (q:R.aqualv)
(x:var{None? (lookup_bvar g x)})
(eq:equiv (extend_env g x ty) e1 e2)
: equiv g (mk_abs ty q (subst_term e1 [ ND x 0 ]))
(mk_abs ty q (subst_term e2 [ ND x 0 ]))
val open_with_gt_ln (e:term) (i:nat) (t:term) (j:nat)
: Lemma
(requires ln' e i /\ i < j)
(ensures subst_term e [ DT j t ] == e)
[SMTPat (ln' e i); SMTPat (subst_term e [ DT j t ])]
//
// Type of the top-level tactic that would splice-in the definitions
//
let fstar_env_fvs (g:R.env) =
lookup_fvar g unit_fv == Some (tm_type u_zero) /\
lookup_fvar g bool_fv == Some (tm_type u_zero) /\
lookup_fvar g b2t_fv == Some b2t_ty
type fstar_env = g:R.env{fstar_env_fvs g}
type fstar_top_env = g:fstar_env {
forall x. None? (lookup_bvar g x )
}
//
// This doesn't allow for universe polymorphic definitions
//
// May be we can change it to:
//
// g:fstar_top_env -> T.tac ((us, e, t):(univ_names & term & typ){typing (push g us) e t})
//
noeq
type sigelt_typing : env -> sigelt -> Type0 =
| ST_Let :
g : env ->
fv : R.fv ->
ty : R.typ ->
tm : R.term ->
squash (typing g tm (T.E_Total, ty)) ->
sigelt_typing g (pack_sigelt (Sg_Let false [pack_lb ({ lb_fv = fv; lb_us = []; lb_typ = ty; lb_def = tm })]))
| ST_Let_Opaque :
g : env ->
fv : R.fv ->
ty : R.typ ->
(* no tm: only a proof of existence *)
squash (exists (tm:R.term). typing g tm (T.E_Total, ty)) ->
sigelt_typing g (pack_sigelt (Sg_Let false [pack_lb ({ lb_fv = fv; lb_us = []; lb_typ = ty; lb_def = (`_) })]))
(**
* The type of the top-level tactic that would splice-in the definitions.
* It returns a list of well typed definitions, via the judgment above.
*
* Each definition can have a 'blob' attached with a given name.
* The blob can be used later, e.g., during extraction, and passed back to the
* extension to perform additional processing.
*)
(*
* It returns either:
* - Some tm, blob, typ, with a proof that `typing g tm typ`
* - None, blob, typ), with a proof that `exists tm. typing g tm typ`
* The blob itself is optional and can store some additional metadata that
* constructed by the tactic. If present, it will be stored in the
* sigmeta_extension_data field of the enclosing sigelt.
*
*)
let blob = string & R.term
(* If checked is true, this sigelt is properly typed for the environment. If not,
we don't know and let F* re-typecheck the sigelt. *)
let sigelt_for (g:env) =
tup:(bool & sigelt & option blob)
{
let (checked, se, _) = tup in
checked ==> sigelt_typing g se
}
let dsl_tac_result_t (g:env) = list (sigelt_for g)
type dsl_tac_t = g:fstar_top_env -> T.Tac (dsl_tac_result_t g)
val if_complete_match (g:env) (t:term)
: T.match_complete_token g t bool_ty [
Pat_Constant C_True;
Pat_Constant C_False;
] [[]; []]
// Derived rule for if
val mkif
(g:fstar_env)
(scrutinee:term)
(then_:term)
(else_:term)
(ty:term)
(u_ty:universe)
(hyp:var { None? (lookup_bvar g hyp) /\ ~(hyp `Set.mem` (freevars then_ `Set.union` freevars else_)) })
(eff:T.tot_or_ghost)
(ty_eff:T.tot_or_ghost)
(ts : typing g scrutinee (eff, bool_ty))
(tt : typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee true_bool)) then_ (eff, ty))
(te : typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee false_bool)) else_ (eff, ty))
(tr : typing g ty (ty_eff, tm_type u_ty))
: typing g (mk_if scrutinee then_ else_) (eff, ty) | false | false | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_checked_let (g: R.env) (nm: string) (tm: R.term) (ty: R.typ{typing g tm (T.E_Total, ty)})
: T.Tac (sigelt_for g) | [] | FStar.Reflection.Typing.mk_checked_let | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
g: FStar.Reflection.Types.env ->
nm: Prims.string ->
tm: FStar.Reflection.Types.term ->
ty:
FStar.Reflection.Types.typ
{FStar.Reflection.Typing.typing g tm (FStar.Stubs.TypeChecker.Core.E_Total, ty)}
-> FStar.Tactics.Effect.Tac (FStar.Reflection.Typing.sigelt_for g) | {
"end_col": 20,
"end_line": 1839,
"start_col": 117,
"start_line": 1832
} |
FStar.Tactics.Effect.Tac | val mk_unchecked_let (g: R.env) (nm: string) (tm: R.term) (ty: R.typ) : T.Tac (sigelt_for g) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"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.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_unchecked_let (g:R.env) (nm:string) (tm:R.term) (ty:R.typ) : T.Tac (sigelt_for g) =
let fv = pack_fv (T.cur_module () @ [nm]) in
let lb = R.pack_lb ({ lb_fv = fv; lb_us = []; lb_typ = ty; lb_def = tm }) in
let se = R.pack_sigelt (R.Sg_Let false [lb]) in
( false, se, None ) | val mk_unchecked_let (g: R.env) (nm: string) (tm: R.term) (ty: R.typ) : T.Tac (sigelt_for g)
let mk_unchecked_let (g: R.env) (nm: string) (tm: R.term) (ty: R.typ) : T.Tac (sigelt_for g) = | true | null | false | let fv = pack_fv (T.cur_module () @ [nm]) in
let lb = R.pack_lb ({ lb_fv = fv; lb_us = []; lb_typ = ty; lb_def = tm }) in
let se = R.pack_sigelt (R.Sg_Let false [lb]) in
(false, se, None) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.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": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [] | [
"FStar.Reflection.Types.env",
"Prims.string",
"FStar.Reflection.Types.term",
"FStar.Reflection.Types.typ",
"FStar.Pervasives.Native.Mktuple3",
"Prims.bool",
"FStar.Reflection.Types.sigelt",
"FStar.Pervasives.Native.option",
"FStar.Reflection.Typing.blob",
"FStar.Pervasives.Native.None",
"FStar.Reflection.V2.Builtins.pack_sigelt",
"FStar.Reflection.V2.Data.Sg_Let",
"Prims.Cons",
"FStar.Reflection.Types.letbinding",
"Prims.Nil",
"FStar.Reflection.V2.Builtins.pack_lb",
"FStar.Reflection.V2.Data.Mklb_view",
"FStar.Reflection.Types.univ_name",
"FStar.Reflection.Typing.sigelt_for",
"FStar.Reflection.Types.fv",
"FStar.Reflection.V2.Builtins.pack_fv",
"FStar.Reflection.Types.name",
"FStar.List.Tot.Base.op_At",
"Prims.list",
"FStar.Tactics.V2.Derived.cur_module"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"]
let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f)
let rec __close_term_vs (i:nat) (vs : list var) (t : term) : Tot term (decreases vs) =
match vs with
| [] -> t
| v::vs ->
subst_term (__close_term_vs (i+1) vs t) [ND v i]
let close_term_vs (vs : list var) (t : term) : term =
__close_term_vs 0 vs t
let close_term_bs (bs : list binding) (t : term) : term =
close_term_vs (List.Tot.map fst bs) t
let bindings_to_refl_bindings (bs : list binding) : list R.binding =
L.map (fun (v, ty) -> {uniq=v; sort=ty; ppname = pp_name_default}) bs
let refl_bindings_to_bindings (bs : list R.binding) : list binding =
L.map (fun b -> b.uniq, b.sort) bs
[@@ no_auto_projectors]
noeq
type non_informative : env -> term -> Type0 =
| Non_informative_type:
g:env ->
u:universe ->
non_informative g (pack_ln (Tv_Type u))
| Non_informative_fv:
g:env ->
x:fv{is_non_informative_fv x} ->
non_informative g (pack_ln (Tv_FVar x))
| Non_informative_uinst:
g:env ->
x:fv{is_non_informative_fv x} ->
us:list universe ->
non_informative g (pack_ln (Tv_UInst x us))
| Non_informative_app:
g:env ->
t:term ->
arg:argv ->
non_informative g t ->
non_informative g (pack_ln (Tv_App t arg))
| Non_informative_total_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g t1 ->
non_informative g (mk_arrow_ct t0 q (T.E_Total, t1))
| Non_informative_ghost_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g (mk_arrow_ct t0 q (T.E_Ghost, t1))
| Non_informative_token:
g:env ->
t:typ ->
squash (T.non_informative_token g t) ->
non_informative g t
val bindings_ok_for_pat : env -> list R.binding -> pattern -> Type0
val bindings_ok_pat_constant :
g:env -> c:R.vconst -> Lemma (bindings_ok_for_pat g [] (Pat_Constant c))
let bindings_ok_for_branch (g:env) (bs : list R.binding) (br : branch) : Type0 =
bindings_ok_for_pat g bs (fst br)
let bindings_ok_for_branch_N (g:env) (bss : list (list R.binding)) (brs : list branch) =
zip2prop (bindings_ok_for_branch g) bss brs
let binding_to_namedv (b:R.binding) : Tot namedv =
pack_namedv {
RD.uniq = b.uniq;
RD.sort = seal b.sort;
RD.ppname = b.ppname;
}
(* Elaborates the p pattern into a term, using the bs bindings for the
pattern variables. The resulting term is properly scoped only on an
environment which contains all of bs. See for instance the branch_typing
judg. Returns an option, since this can fail if e.g. there are not
enough bindings, and returns the list of unused binders as well, which
should be empty if the list of binding was indeed ok. *)
let rec elaborate_pat (p : pattern) (bs : list R.binding) : Tot (option (term & list R.binding)) (decreases p) =
match p, bs with
| Pat_Constant c, _ -> Some (pack_ln (Tv_Const c), bs)
| Pat_Cons fv univs subpats, bs ->
let head = pack_ln (Tv_FVar fv) in
fold_left_dec
(Some (head, bs))
subpats
(fun st pi ->
let (p,i) = pi in
match st with | None -> None | Some (head, bs) ->
match elaborate_pat p bs with | None -> None | Some (t, bs') -> Some (pack_ln (Tv_App head (t, (if i then Q_Implicit else Q_Explicit))), bs'))
| Pat_Var _ _, b::bs ->
Some (pack_ln (Tv_Var (binding_to_namedv b)), bs)
| Pat_Dot_Term (Some t), _ -> Some (t, bs)
| Pat_Dot_Term None, _ -> None
| _ -> None
[@@ no_auto_projectors]
noeq
type typing : env -> term -> comp_typ -> Type0 =
| T_Token :
g:env ->
e:term ->
c:comp_typ ->
squash (T.typing_token g e c) ->
typing g e c
| T_Var :
g:env ->
x:namedv { Some? (lookup_bvar g (namedv_uniq x)) } ->
typing g (pack_ln (Tv_Var x)) (T.E_Total, Some?.v (lookup_bvar g (namedv_uniq x)))
| T_FVar :
g:env ->
x:fv { Some? (lookup_fvar g x) } ->
typing g (pack_ln (Tv_FVar x)) (T.E_Total, Some?.v (lookup_fvar g x))
| T_UInst :
g:env ->
x:fv ->
us:list universe { Some? (lookup_fvar_uinst g x us) } ->
typing g (pack_ln (Tv_UInst x us)) (T.E_Total, Some?.v (lookup_fvar_uinst g x us))
| T_Const:
g:env ->
v:vconst ->
t:term ->
constant_typing v t ->
typing g (constant_as_term v) (T.E_Total, t)
| T_Abs :
g:env ->
x:var { None? (lookup_bvar g x) } ->
ty:term ->
body:term { ~(x `Set.mem` freevars body) } ->
body_c:comp_typ ->
u:universe ->
pp_name:pp_name_t ->
q:aqualv ->
ty_eff:T.tot_or_ghost ->
typing g ty (ty_eff, tm_type u) ->
typing (extend_env g x ty) (open_term body x) body_c ->
typing g (pack_ln (Tv_Abs (mk_binder pp_name ty q) body))
(T.E_Total,
pack_ln (Tv_Arrow (mk_binder pp_name ty q)
(mk_comp (close_comp_typ body_c x))))
| T_App :
g:env ->
e1:term ->
e2:term ->
x:binder ->
t:term ->
eff:T.tot_or_ghost ->
typing g e1 (eff, pack_ln (Tv_Arrow x (mk_comp (eff, t)))) ->
typing g e2 (eff, binder_sort x) ->
typing g (pack_ln (Tv_App e1 (e2, binder_qual x)))
(eff, open_with t e2)
| T_Let:
g:env ->
x:var { None? (lookup_bvar g x) } ->
e1:term ->
t1:typ ->
e2:term ->
t2:typ ->
eff:T.tot_or_ghost ->
pp_name:pp_name_t ->
typing g e1 (eff, t1) ->
typing (extend_env g x t1) (open_term e2 x) (eff, t2) ->
typing g (mk_let pp_name e1 t1 e2) (eff, open_with (close_term t2 x) e1)
| T_Arrow:
g:env ->
x:var { None? (lookup_bvar g x) } ->
t1:term ->
t2:term { ~(x `Set.mem` freevars t2) } ->
u1:universe ->
u2:universe ->
pp_name:pp_name_t ->
q:aqualv ->
eff:T.tot_or_ghost ->
t1_eff:T.tot_or_ghost ->
t2_eff:T.tot_or_ghost ->
typing g t1 (t1_eff, tm_type u1) ->
typing (extend_env g x t1) (open_term t2 x) (t2_eff, tm_type u2) ->
typing g (pack_ln (Tv_Arrow (mk_binder pp_name t1 q) (mk_comp (eff, t2))))
(T.E_Total, tm_type (u_max u1 u2))
| T_Refine:
g:env ->
x:var { None? (lookup_bvar g x) } ->
t:term ->
e:term { ~(x `Set.mem` freevars e) } ->
u1:universe ->
u2:universe ->
t_eff:T.tot_or_ghost ->
e_eff:T.tot_or_ghost ->
typing g t (t_eff, tm_type u1) ->
typing (extend_env g x t) (open_term e x) (e_eff, tm_type u2) ->
typing g (pack_ln (Tv_Refine (mk_simple_binder pp_name_default t) e)) (T.E_Total, tm_type u1)
| T_PropIrrelevance:
g:env ->
e:term ->
t:term ->
e_eff:T.tot_or_ghost ->
t_eff:T.tot_or_ghost ->
typing g e (e_eff, t) ->
typing g t (t_eff, tm_prop) ->
typing g (`()) (T.E_Total, t)
| T_Sub:
g:env ->
e:term ->
c:comp_typ ->
c':comp_typ ->
typing g e c ->
sub_comp g c c' ->
typing g e c'
| T_If:
g:env ->
scrutinee:term ->
then_:term ->
else_:term ->
ty:term ->
u_ty:universe ->
hyp:var { None? (lookup_bvar g hyp) /\ ~(hyp `Set.mem` (freevars then_ `Set.union` freevars else_)) } ->
eff:T.tot_or_ghost ->
ty_eff:T.tot_or_ghost ->
typing g scrutinee (eff, bool_ty) ->
typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee true_bool)) then_ (eff, ty) ->
typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee false_bool)) else_ (eff, ty) ->
typing g ty (ty_eff, tm_type u_ty) -> //typedness of ty cannot rely on hyp
typing g (mk_if scrutinee then_ else_) (eff, ty)
| T_Match:
g:env ->
sc_u : universe ->
sc_ty : typ ->
sc : term ->
ty_eff:T.tot_or_ghost ->
typing g sc_ty (ty_eff, tm_type sc_u) ->
eff:T.tot_or_ghost ->
typing g sc (eff, sc_ty) ->
branches:list branch ->
ty:comp_typ ->
bnds:list (list R.binding) ->
complet : match_is_complete g sc sc_ty (List.Tot.map fst branches) bnds -> // complete patterns
branches_typing g sc_u sc_ty sc ty branches bnds -> // each branch has proper type
typing g (pack_ln (Tv_Match sc None branches)) ty
and related : env -> term -> relation -> term -> Type0 =
| Rel_refl:
g:env ->
t:term ->
rel:relation ->
related g t rel t
| Rel_sym:
g:env ->
t0:term ->
t1:term ->
related g t0 R_Eq t1 ->
related g t1 R_Eq t0
| Rel_trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
rel:relation ->
related g t0 rel t1 ->
related g t1 rel t2 ->
related g t0 rel t2
| Rel_univ:
g:env ->
u:universe ->
v:universe ->
univ_eq u v ->
related g (tm_type u) R_Eq (tm_type v)
| Rel_beta:
g:env ->
t:typ ->
q:aqualv ->
e:term { ln' e 0 } ->
arg:term { ln arg } ->
related g (R.pack_ln (R.Tv_App (mk_abs t q e) (arg, q)))
R_Eq
(subst_term e [ DT 0 arg ])
| Rel_eq_token:
g:env ->
t0:term ->
t1:term ->
squash (T.equiv_token g t0 t1) ->
related g t0 R_Eq t1
| Rel_subtyping_token:
g:env ->
t0:term ->
t1:term ->
squash (T.subtyping_token g t0 t1) ->
related g t0 R_Sub t1
| Rel_equiv:
g:env ->
t0:term ->
t1:term ->
rel:relation ->
related g t0 R_Eq t1 ->
related g t0 rel t1
| Rel_arrow:
g:env ->
t1:term ->
t2:term ->
q:aqualv ->
c1:comp_typ ->
c2:comp_typ ->
rel:relation ->
x:var{
None? (lookup_bvar g x) /\
~ (x `Set.mem` (freevars_comp_typ c1 `Set.union` freevars_comp_typ c2))
} ->
related g t2 rel t1 ->
related_comp (extend_env g x t2)
(open_comp_typ c1 x)
rel
(open_comp_typ c2 x) ->
related g (mk_arrow_ct t1 q c1) rel (mk_arrow_ct t2 q c2)
| Rel_abs:
g:env ->
t1:term ->
t2:term ->
q:aqualv ->
e1:term ->
e2:term ->
x:var{
None? (lookup_bvar g x) /\ ~ (x `Set.mem` (freevars e1 `Set.union` freevars e2))
} ->
related g t1 R_Eq t2 ->
related (extend_env g x t1)
(subst_term e1 (open_with_var x 0))
R_Eq
(subst_term e2 (open_with_var x 0)) ->
related g (mk_abs t1 q e1) R_Eq (mk_abs t2 q e2)
| Rel_ctxt:
g:env ->
t0:term ->
t1:term ->
ctxt:term_ctxt ->
related g t0 R_Eq t1 ->
related g (apply_term_ctxt ctxt t0) R_Eq (apply_term_ctxt ctxt t1)
and related_comp : env -> comp_typ -> relation -> comp_typ -> Type0 =
| Relc_typ:
g:env ->
t0:term ->
t1:term ->
eff:T.tot_or_ghost ->
rel:relation ->
related g t0 rel t1 ->
related_comp g (eff, t0) rel (eff, t1)
| Relc_total_ghost:
g:env ->
t:term ->
related_comp g (T.E_Total, t) R_Sub (T.E_Ghost, t)
| Relc_ghost_total:
g:env ->
t:term ->
non_informative g t ->
related_comp g (T.E_Ghost, t) R_Sub (T.E_Total, t)
and branches_typing (g:env) (sc_u:universe) (sc_ty:typ) (sc:term) (rty:comp_typ)
: (brs:list branch) -> (bnds : list (list R.binding)) -> Type0
=
(* This judgement only enforces that branch_typing holds for every
element of brs and its respective bnds (which must have the same
length). *)
| BT_Nil :
branches_typing g sc_u sc_ty sc rty [] []
| BT_S :
br : branch ->
bnds : list R.binding ->
pf : branch_typing g sc_u sc_ty sc rty br bnds ->
rest_br : list branch ->
rest_bnds : list (list R.binding) ->
rest : branches_typing g sc_u sc_ty sc rty rest_br rest_bnds ->
branches_typing g sc_u sc_ty sc rty (br :: rest_br) (bnds :: rest_bnds)
and branch_typing (g:env) (sc_u:universe) (sc_ty:typ) (sc:term) (rty:comp_typ)
: (br : branch) -> (bnds : list R.binding) -> Type0
=
| BO :
pat : pattern ->
bnds : list R.binding{bindings_ok_for_pat g bnds pat} ->
hyp_var:var{None? (lookup_bvar (extend_env_l g (refl_bindings_to_bindings bnds)) hyp_var)} ->
body:term ->
_ : squash (Some? (elaborate_pat pat bnds)) ->
typing (extend_env
(extend_env_l g (refl_bindings_to_bindings bnds))
hyp_var (eq2 sc_u sc_ty sc (fst (Some?.v (elaborate_pat pat bnds))))
)
body rty ->
branch_typing g sc_u sc_ty sc rty
(pat, close_term_bs (refl_bindings_to_bindings bnds) body)
bnds
and match_is_complete : env -> term -> typ -> list pattern -> list (list R.binding) -> Type0 =
| MC_Tok :
env:_ ->
sc:_ ->
ty:_ ->
pats:_ ->
bnds:_ ->
squash (T.match_complete_token env sc ty pats bnds) -> match_is_complete env sc ty pats bnds
and sub_typing (g:env) (t1 t2:term) = related g t1 R_Sub t2
and sub_comp (g:env) (c1 c2:comp_typ) = related_comp g c1 R_Sub c2
and equiv (g:env) (t1 t2:term) = related g t1 R_Eq t2
type tot_typing (g:env) (e:term) (t:term) = typing g e (T.E_Total, t)
type ghost_typing (g:env) (e:term) (t:term) = typing g e (T.E_Ghost, t)
val subtyping_token_renaming (g:env)
(bs0:bindings)
(bs1:bindings)
(x:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) x) })
(y:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) y) })
(t:term)
(t0 t1:term)
(d:T.subtyping_token (extend_env_l g (bs1@(x,t)::bs0)) t0 t1)
: T.subtyping_token (extend_env_l g (rename_bindings bs1 x y@(y,t)::bs0))
(rename t0 x y)
(rename t1 x y)
val subtyping_token_weakening (g:env)
(bs0:bindings)
(bs1:bindings)
(x:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) x) })
(t:term)
(t0 t1:term)
(d:T.subtyping_token (extend_env_l g (bs1@bs0)) t0 t1)
: T.subtyping_token (extend_env_l g (bs1@(x,t)::bs0)) t0 t1
let simplify_umax (#g:R.env) (#t:R.term) (#u:R.universe)
(d:typing g t (T.E_Total, tm_type (u_max u u)))
: typing g t (T.E_Total, tm_type u)
= let ue
: univ_eq (u_max u u) u
= UN_MaxLeq u u (UNLEQ_Refl u)
in
let du : related g (tm_type (u_max u u)) R_Eq (tm_type u)
= Rel_univ g (u_max u u) u ue in
let du : related g (tm_type (u_max u u)) R_Sub (tm_type u)
= Rel_equiv _ _ _ _ du in
T_Sub _ _ _ _ d (Relc_typ _ _ _ T.E_Total _ du)
val well_typed_terms_are_ln (g:R.env) (e:R.term) (c:comp_typ) (_:typing g e c)
: Lemma (ensures ln e /\ ln (snd c))
val type_correctness (g:R.env) (e:R.term) (c:comp_typ) (_:typing g e c)
: GTot (u:R.universe & typing g (snd c) (T.E_Total, tm_type u))
val binder_offset_pattern_invariant (p:pattern) (ss:subst)
: Lemma (binder_offset_pattern p == binder_offset_pattern (subst_pattern p ss))
val binder_offset_patterns_invariant (p:list (pattern & bool)) (ss:subst)
: Lemma (binder_offset_patterns p == binder_offset_patterns (subst_patterns p ss))
val open_close_inverse' (i:nat) (t:term { ln' t (i - 1) }) (x:var)
: Lemma
(ensures subst_term
(subst_term t [ ND x i ])
(open_with_var x i)
== t)
val open_close_inverse'_binder (i:nat) (b:binder { ln'_binder b (i - 1) }) (x:var)
: Lemma (ensures subst_binder
(subst_binder b [ ND x i ])
(open_with_var x i)
== b)
val open_close_inverse'_terms (i:nat) (ts:list term { ln'_terms ts (i - 1) }) (x:var)
: Lemma (ensures subst_terms
(subst_terms ts [ ND x i ])
(open_with_var x i)
== ts)
val open_close_inverse'_comp (i:nat) (c:comp { ln'_comp c (i - 1) }) (x:var)
: Lemma
(ensures subst_comp
(subst_comp c [ ND x i ])
(open_with_var x i)
== c)
val open_close_inverse'_args (i:nat)
(ts:list argv { ln'_args ts (i - 1) })
(x:var)
: Lemma
(ensures subst_args
(subst_args ts [ ND x i ])
(open_with_var x i)
== ts)
val open_close_inverse'_patterns (i:nat)
(ps:list (pattern & bool) { ln'_patterns ps (i - 1) })
(x:var)
: Lemma
(ensures subst_patterns
(subst_patterns ps [ ND x i ])
(open_with_var x i)
== ps)
val open_close_inverse'_pattern (i:nat) (p:pattern{ln'_pattern p (i - 1)}) (x:var)
: Lemma
(ensures subst_pattern
(subst_pattern p [ ND x i ])
(open_with_var x i)
== p)
val open_close_inverse'_branch (i:nat) (br:branch{ln'_branch br (i - 1)}) (x:var)
: Lemma
(ensures subst_branch
(subst_branch br [ ND x i ])
(open_with_var x i)
== br)
val open_close_inverse'_branches (i:nat)
(brs:list branch { ln'_branches brs (i - 1) })
(x:var)
: Lemma
(ensures subst_branches
(subst_branches brs [ ND x i ])
(open_with_var x i)
== brs)
val open_close_inverse'_match_returns (i:nat)
(m:match_returns_ascription { ln'_match_returns m (i - 1) })
(x:var)
: Lemma
(ensures subst_match_returns
(subst_match_returns m [ ND x i ])
(open_with_var x i)
== m)
val open_close_inverse (e:R.term { ln e }) (x:var)
: Lemma (open_term (close_term e x) x == e)
val close_open_inverse' (i:nat)
(t:term)
(x:var { ~(x `Set.mem` freevars t) })
: Lemma
(ensures subst_term
(subst_term t (open_with_var x i))
[ ND x i ]
== t)
val close_open_inverse'_comp (i:nat)
(c:comp)
(x:var{ ~(x `Set.mem` freevars_comp c) })
: Lemma
(ensures subst_comp
(subst_comp c (open_with_var x i))
[ ND x i ]
== c)
val close_open_inverse'_args (i:nat) (args:list argv) (x:var{ ~(x `Set.mem` freevars_args args) })
: Lemma
(ensures subst_args
(subst_args args (open_with_var x i))
[ ND x i]
== args)
val close_open_inverse'_binder (i:nat) (b:binder) (x:var{ ~(x `Set.mem` freevars_binder b) })
: Lemma
(ensures subst_binder
(subst_binder b (open_with_var x i))
[ ND x i ]
== b)
val close_open_inverse'_terms (i:nat) (ts:list term) (x:var{ ~(x `Set.mem` freevars_terms ts) })
: Lemma
(ensures subst_terms
(subst_terms ts (open_with_var x i))
[ ND x i ]
== ts)
val close_open_inverse'_branches (i:nat) (brs:list branch)
(x:var{ ~(x `Set.mem` freevars_branches brs) })
: Lemma
(ensures subst_branches
(subst_branches brs (open_with_var x i))
[ ND x i ]
== brs)
val close_open_inverse'_branch (i:nat)
(br:branch)
(x:var{ ~(x `Set.mem` freevars_branch br) })
: Lemma
(ensures subst_branch
(subst_branch br (open_with_var x i))
[ ND x i ]
== br)
val close_open_inverse'_pattern (i:nat)
(p:pattern)
(x:var{ ~(x `Set.mem` freevars_pattern p) })
: Lemma
(ensures subst_pattern
(subst_pattern p (open_with_var x i))
[ ND x i ]
== p)
val close_open_inverse'_patterns (i:nat)
(ps:list (pattern & bool))
(x:var {~ (x `Set.mem` freevars_patterns ps) })
: Lemma
(ensures subst_patterns
(subst_patterns ps (open_with_var x i))
[ ND x i ]
== ps)
val close_open_inverse'_match_returns (i:nat) (m:match_returns_ascription)
(x:var{ ~(x `Set.mem` freevars_match_returns m) })
: Lemma
(ensures subst_match_returns
(subst_match_returns m (open_with_var x i))
[ ND x i ]
== m)
val close_open_inverse (e:R.term) (x:var {~ (x `Set.mem` freevars e) })
: Lemma (close_term (open_term e x) x == e)
//
// fst has corresponding lemmas for other syntax classes
//
val close_with_not_free_var (t:R.term) (x:var) (i:nat)
: Lemma
(requires ~ (Set.mem x (freevars t)))
(ensures subst_term t [ ND x i ] == t)
// this also requires x to be not in freevars e1 `Set.union` freevars e2
val equiv_arrow (#g:R.env) (#e1 #e2:R.term) (ty:R.typ) (q:R.aqualv)
(x:var { None? (lookup_bvar g x) })
(eq:equiv (extend_env g x ty)
(subst_term e1 (open_with_var x 0))
(subst_term e2 (open_with_var x 0)))
: equiv g (mk_arrow ty q e1)
(mk_arrow ty q e2)
// the proof for this requires e1 and e2 to be ln
val equiv_abs_close (#g:R.env) (#e1 #e2:R.term) (ty:R.typ) (q:R.aqualv)
(x:var{None? (lookup_bvar g x)})
(eq:equiv (extend_env g x ty) e1 e2)
: equiv g (mk_abs ty q (subst_term e1 [ ND x 0 ]))
(mk_abs ty q (subst_term e2 [ ND x 0 ]))
val open_with_gt_ln (e:term) (i:nat) (t:term) (j:nat)
: Lemma
(requires ln' e i /\ i < j)
(ensures subst_term e [ DT j t ] == e)
[SMTPat (ln' e i); SMTPat (subst_term e [ DT j t ])]
//
// Type of the top-level tactic that would splice-in the definitions
//
let fstar_env_fvs (g:R.env) =
lookup_fvar g unit_fv == Some (tm_type u_zero) /\
lookup_fvar g bool_fv == Some (tm_type u_zero) /\
lookup_fvar g b2t_fv == Some b2t_ty
type fstar_env = g:R.env{fstar_env_fvs g}
type fstar_top_env = g:fstar_env {
forall x. None? (lookup_bvar g x )
}
//
// This doesn't allow for universe polymorphic definitions
//
// May be we can change it to:
//
// g:fstar_top_env -> T.tac ((us, e, t):(univ_names & term & typ){typing (push g us) e t})
//
noeq
type sigelt_typing : env -> sigelt -> Type0 =
| ST_Let :
g : env ->
fv : R.fv ->
ty : R.typ ->
tm : R.term ->
squash (typing g tm (T.E_Total, ty)) ->
sigelt_typing g (pack_sigelt (Sg_Let false [pack_lb ({ lb_fv = fv; lb_us = []; lb_typ = ty; lb_def = tm })]))
| ST_Let_Opaque :
g : env ->
fv : R.fv ->
ty : R.typ ->
(* no tm: only a proof of existence *)
squash (exists (tm:R.term). typing g tm (T.E_Total, ty)) ->
sigelt_typing g (pack_sigelt (Sg_Let false [pack_lb ({ lb_fv = fv; lb_us = []; lb_typ = ty; lb_def = (`_) })]))
(**
* The type of the top-level tactic that would splice-in the definitions.
* It returns a list of well typed definitions, via the judgment above.
*
* Each definition can have a 'blob' attached with a given name.
* The blob can be used later, e.g., during extraction, and passed back to the
* extension to perform additional processing.
*)
(*
* It returns either:
* - Some tm, blob, typ, with a proof that `typing g tm typ`
* - None, blob, typ), with a proof that `exists tm. typing g tm typ`
* The blob itself is optional and can store some additional metadata that
* constructed by the tactic. If present, it will be stored in the
* sigmeta_extension_data field of the enclosing sigelt.
*
*)
let blob = string & R.term
(* If checked is true, this sigelt is properly typed for the environment. If not,
we don't know and let F* re-typecheck the sigelt. *)
let sigelt_for (g:env) =
tup:(bool & sigelt & option blob)
{
let (checked, se, _) = tup in
checked ==> sigelt_typing g se
}
let dsl_tac_result_t (g:env) = list (sigelt_for g)
type dsl_tac_t = g:fstar_top_env -> T.Tac (dsl_tac_result_t g)
val if_complete_match (g:env) (t:term)
: T.match_complete_token g t bool_ty [
Pat_Constant C_True;
Pat_Constant C_False;
] [[]; []]
// Derived rule for if
val mkif
(g:fstar_env)
(scrutinee:term)
(then_:term)
(else_:term)
(ty:term)
(u_ty:universe)
(hyp:var { None? (lookup_bvar g hyp) /\ ~(hyp `Set.mem` (freevars then_ `Set.union` freevars else_)) })
(eff:T.tot_or_ghost)
(ty_eff:T.tot_or_ghost)
(ts : typing g scrutinee (eff, bool_ty))
(tt : typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee true_bool)) then_ (eff, ty))
(te : typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee false_bool)) else_ (eff, ty))
(tr : typing g ty (ty_eff, tm_type u_ty))
: typing g (mk_if scrutinee then_ else_) (eff, ty)
(* Helper to return a single let definition in a splice_t tactic. *)
let mk_checked_let (g:R.env) (nm:string) (tm:R.term) (ty:R.typ{typing g tm (T.E_Total, ty)}) : T.Tac (sigelt_for g) =
let fv = pack_fv (T.cur_module () @ [nm]) in
let lb = R.pack_lb ({ lb_fv = fv; lb_us = []; lb_typ = ty; lb_def = tm }) in
let se = R.pack_sigelt (R.Sg_Let false [lb]) in
let pf : sigelt_typing g se =
ST_Let g fv ty tm ()
in
( true, se, None ) | false | false | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_unchecked_let (g: R.env) (nm: string) (tm: R.term) (ty: R.typ) : T.Tac (sigelt_for g) | [] | FStar.Reflection.Typing.mk_unchecked_let | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
g: FStar.Reflection.Types.env ->
nm: Prims.string ->
tm: FStar.Reflection.Types.term ->
ty: FStar.Reflection.Types.typ
-> FStar.Tactics.Effect.Tac (FStar.Reflection.Typing.sigelt_for g) | {
"end_col": 21,
"end_line": 1845,
"start_col": 90,
"start_line": 1841
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Definitions.Lemmas",
"short_module": "LD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.MathLemmas",
"short_module": "ML"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let normalize5_first_part (f0,f1,f2,f3,f4) =
let (t0,t1,t2,t3,t4) = normalize_weak5 (f0,f1,f2,f3,f4) in
let x, (r0,r1,r2,r3,r4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
x, (r0,r1,r2,r3,r4) | let normalize5_first_part (f0, f1, f2, f3, f4) = | false | null | false | let t0, t1, t2, t3, t4 = normalize_weak5 (f0, f1, f2, f3, f4) in
let x, (r0, r1, r2, r3, r4) = minus_x_mul_pow2_256 (t0, t1, t2, t3, t4) in
x, (r0, r1, r2, r3, r4) | {
"checked_file": "Hacl.Spec.K256.Field52.Lemmas2.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.MathLemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.Lemmas2.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple5",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.Mktuple5",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Hacl.Spec.K256.Field52.minus_x_mul_pow2_256",
"Hacl.Spec.K256.Field52.normalize_weak5"
] | [] | module Hacl.Spec.K256.Field52.Lemmas2
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
include Hacl.Spec.K256.Field52
module ML = Hacl.Spec.K256.MathLemmas
module LD = Hacl.Spec.K256.Field52.Definitions.Lemmas
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
/// Normalize-weak
val minus_x_mul_pow2_256_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires felem_fits5 f m)
(ensures
(let x, r = minus_x_mul_pow2_256 f in
let (r0,r1,r2,r3,r4) = r in
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
v x < pow2 16 /\ v x = v t4 / pow2 48 /\
v r4 = v t4 % pow2 48 /\
as_nat5 r == as_nat5 f - v x * pow2 256 /\
felem_fits5 r (m0,m1,m2,m3,1)))
let minus_x_mul_pow2_256_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
let x = t4 >>. 48ul in let t4' = t4 &. mask48 in
LD.lemma_mask48 t4;
let r = (t0,t1,t2,t3,t4') in
calc (==) { // as_nat5 f
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + v t4 * pow208;
(==) { Math.Lemmas.euclidean_division_definition (v t4) (pow2 48) }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48 + v t4 % pow2 48) * pow208;
(==) { Math.Lemmas.distributivity_add_left (v t4 / pow2 48 * pow2 48) (v t4 % pow2 48) pow208 }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48) * pow208 + (v t4 % pow2 48) * pow208;
(==) { }
(v x * pow2 48) * pow208 + as_nat5 r;
(==) { Math.Lemmas.paren_mul_right (v x) (pow2 48) pow208; Math.Lemmas.pow2_plus 48 208 }
v x * pow2 256 + as_nat5 r;
};
Math.Lemmas.lemma_div_lt (v t4) 64 48
val carry_round_after_last_carry_mod_prime5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f (m0,m1,m2,m3,1)))
(ensures (let r = carry_round5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let carry_round_after_last_carry_mod_prime5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in //(m0,m1,m2,m3,1)
let t1' = t1 +. (t0 >>. 52ul) in let t0' = t0 &. mask52 in
LD.lemma_carry52 m1 m0 t1 t0;
assert (felem_fits1 t1' (m1 + 1));
assert (felem_fits1 t0' 1);
assert (v t0' = v t0 % pow2 52);
assert (v t1' = v t1 + v t0 / pow2 52);
let t2' = t2 +. (t1' >>. 52ul) in let t1'' = t1' &. mask52 in
LD.lemma_carry52 m2 (m1 + 1) t2 t1';
assert (felem_fits1 t2' (m2 + 1));
assert (felem_fits1 t1'' 1);
assert (v t1'' = v t1' % pow2 52);
assert (v t2' = v t2 + v t1' / pow2 52);
let t3' = t3 +. (t2' >>. 52ul) in let t2'' = t2' &. mask52 in
LD.lemma_carry52 m3 (m2 + 1) t3 t2';
assert (felem_fits1 t3' (m3 + 1));
assert (felem_fits1 t2'' 1);
assert (v t2'' = v t2' % pow2 52);
assert (v t3' = v t3 + v t2' / pow2 52);
let t4' = t4 +. (t3' >>. 52ul) in let t3'' = t3' &. mask52 in
LD.lemma_carry_last52 m4 (m3 + 1) t4 t3';
assert (felem_fits_last1 t4' (m4 + 1));
assert (felem_fits1 t3'' 1);
assert (v t3'' = v t3' % pow2 52);
assert (v t4' = v t4 + v t3' / pow2 52);
LD.carry_last_small_mod_lemma t4 t3';
ML.lemma_simplify_carry_round (v t0) (v t1) (v t2) (v t3) (v t4);
let r = carry_round5 f in
assert ((t0',t1'',t2'',t3'',t4') == r);
assert (as_nat5 r == as_nat5 f)
val plus_x_mul_pow2_256_minus_prime_lemma: m:scale64_5 -> x:uint64 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f m /\ v x < pow2 16))
(ensures
(let r = plus_x_mul_pow2_256_minus_prime x f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime) /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let plus_x_mul_pow2_256_minus_prime_lemma m x f =
let (t0,t1,t2,t3,t4) = f in
let (m0,m1,m2,m3,m4) = m in
let t0' = t0 +. x *. u64 0x1000003D1 in
assert (v x < pow2 16);
Math.Lemmas.lemma_mult_lt_right 0x1000003D1 (v x) (pow2 16);
assert_norm (pow2 16 * 0x1000003D1 < max52);
assert (v t0 + v x * 0x1000003D1 < (m0 + 1) * max52);
Math.Lemmas.lemma_mult_le_right max52 (m0 + 1) 4096;
assert_norm (4096 * max52 < pow2 64);
Math.Lemmas.small_mod (v t0 + v x * 0x1000003D1) (pow2 64);
assert (v t0' = v t0 + v x * 0x1000003D1);
assert (felem_fits1 t0' (m0 + 1));
let r = carry_round5 (t0',t1,t2,t3,t4) in
carry_round_after_last_carry_mod_prime5_lemma (m0+1,m1,m2,m3,m4) (t0',t1,t2,t3,t4);
assert (as_nat5 r == as_nat5 (t0',t1,t2,t3,t4));
LD.lemma_pow2_256_minus_prime ();
assert (as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime))
val normalize_weak5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let r = normalize_weak5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f - v t4 / pow2 48 * S.prime /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let normalize_weak5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let x, f1 = minus_x_mul_pow2_256 f in
minus_x_mul_pow2_256_lemma m f;
assert (as_nat5 f1 == as_nat5 f - v x * pow2 256);
assert (felem_fits5 f1 (m0,m1,m2,m3,1));
let f2 = plus_x_mul_pow2_256_minus_prime x f1 in
plus_x_mul_pow2_256_minus_prime_lemma (m0,m1,m2,m3,1) x f1;
assert (as_nat5 f2 == as_nat5 f1 + v x * (pow2 256 - S.prime));
assert (felem_fits5 f2 (1,1,1,1,2));
assert (f2 == normalize_weak5 f);
Math.Lemmas.distributivity_sub_right (v x) (pow2 256) S.prime;
assert (as_nat5 f2 == as_nat5 f - v x * S.prime)
/// Normalize
#push-options "--ifuel 1"
val is_felem_ge_prime5_lemma: f:felem5 -> Lemma
(requires felem_fits5 f (1,1,1,1,1))
(ensures (let is_m = is_felem_ge_prime5 f in
(v is_m = 0 \/ v is_m = ones_v U64) /\
(if v is_m = ones_v U64 then (as_nat5 f >= S.prime) else (as_nat5 f < S.prime))))
let is_felem_ge_prime5_lemma f = ()
#pop-options
// let (f0,f1,f2,f3,f4) = f in
// let m4 = eq_mask f4 mask48 in
// eq_mask_lemma f4 mask48;
// assert (if v f4 = v mask48 then v m4 = ones_v U64 else v m4 = 0);
// let m3 = eq_mask f3 mask52 in
// eq_mask_lemma f3 mask52;
// assert (if v f3 = v mask52 then v m3 = ones_v U64 else v m3 = 0);
// let m2 = eq_mask f2 mask52 in
// eq_mask_lemma f2 mask52;
// assert (if v f2 = v mask52 then v m2 = ones_v U64 else v m2 = 0);
// let m1 = eq_mask f1 mask52 in
// eq_mask_lemma f1 mask52;
// assert (if v f1 = v mask52 then v m1 = ones_v U64 else v m1 = 0);
// let m0 = gte_mask f0 (u64 0xffffefffffc2f) in
// gte_mask_lemma f0 (u64 0xffffefffffc2f);
// assert (if v f0 >= 0xffffefffffc2f then v m0 = ones_v U64 else v m0 = 0);
// let m = m0 &. m1 &. m2 &. m3 &. m4 in ()
// if v m4 = 0 then
// logand_zeros (m0 &. m1 &. m2 &. m3)
// else begin
// logand_ones (m0 &. m1 &. m2 &. m3) end | false | true | Hacl.Spec.K256.Field52.Lemmas2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val normalize5_first_part : _:
((((Lib.IntTypes.uint64 * Lib.IntTypes.uint64) * Lib.IntTypes.uint64) * Lib.IntTypes.uint64) *
Lib.IntTypes.uint64)
-> Lib.IntTypes.uint64 *
((((Lib.IntTypes.uint64 * Lib.IntTypes.uint64) * Lib.IntTypes.uint64) * Lib.IntTypes.uint64) *
Lib.IntTypes.uint64) | [] | Hacl.Spec.K256.Field52.Lemmas2.normalize5_first_part | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.Lemmas2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
_:
((((Lib.IntTypes.uint64 * Lib.IntTypes.uint64) * Lib.IntTypes.uint64) * Lib.IntTypes.uint64) *
Lib.IntTypes.uint64)
-> Lib.IntTypes.uint64 *
((((Lib.IntTypes.uint64 * Lib.IntTypes.uint64) * Lib.IntTypes.uint64) * Lib.IntTypes.uint64) *
Lib.IntTypes.uint64) | {
"end_col": 21,
"end_line": 208,
"start_col": 44,
"start_line": 205
} |
|
FStar.Pervasives.Lemma | val lemma_a_minus_b_n_c_n_k (k a b c:nat) (n:pos) : Lemma
(requires k < n /\ k == a - b * n - c * n)
(ensures k == a % n) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Definitions.Lemmas",
"short_module": "LD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.MathLemmas",
"short_module": "ML"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_a_minus_b_n_c_n_k k a b c n =
Math.Lemmas.lemma_mod_sub (a - b * n) n c;
Math.Lemmas.lemma_mod_sub a n b;
Math.Lemmas.small_mod k n | val lemma_a_minus_b_n_c_n_k (k a b c:nat) (n:pos) : Lemma
(requires k < n /\ k == a - b * n - c * n)
(ensures k == a % n)
let lemma_a_minus_b_n_c_n_k k a b c n = | false | null | true | Math.Lemmas.lemma_mod_sub (a - b * n) n c;
Math.Lemmas.lemma_mod_sub a n b;
Math.Lemmas.small_mod k n | {
"checked_file": "Hacl.Spec.K256.Field52.Lemmas2.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.MathLemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.Lemmas2.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Prims.pos",
"FStar.Math.Lemmas.small_mod",
"Prims.unit",
"FStar.Math.Lemmas.lemma_mod_sub",
"Prims.op_Subtraction",
"FStar.Mul.op_Star"
] | [] | module Hacl.Spec.K256.Field52.Lemmas2
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
include Hacl.Spec.K256.Field52
module ML = Hacl.Spec.K256.MathLemmas
module LD = Hacl.Spec.K256.Field52.Definitions.Lemmas
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
/// Normalize-weak
val minus_x_mul_pow2_256_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires felem_fits5 f m)
(ensures
(let x, r = minus_x_mul_pow2_256 f in
let (r0,r1,r2,r3,r4) = r in
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
v x < pow2 16 /\ v x = v t4 / pow2 48 /\
v r4 = v t4 % pow2 48 /\
as_nat5 r == as_nat5 f - v x * pow2 256 /\
felem_fits5 r (m0,m1,m2,m3,1)))
let minus_x_mul_pow2_256_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
let x = t4 >>. 48ul in let t4' = t4 &. mask48 in
LD.lemma_mask48 t4;
let r = (t0,t1,t2,t3,t4') in
calc (==) { // as_nat5 f
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + v t4 * pow208;
(==) { Math.Lemmas.euclidean_division_definition (v t4) (pow2 48) }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48 + v t4 % pow2 48) * pow208;
(==) { Math.Lemmas.distributivity_add_left (v t4 / pow2 48 * pow2 48) (v t4 % pow2 48) pow208 }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48) * pow208 + (v t4 % pow2 48) * pow208;
(==) { }
(v x * pow2 48) * pow208 + as_nat5 r;
(==) { Math.Lemmas.paren_mul_right (v x) (pow2 48) pow208; Math.Lemmas.pow2_plus 48 208 }
v x * pow2 256 + as_nat5 r;
};
Math.Lemmas.lemma_div_lt (v t4) 64 48
val carry_round_after_last_carry_mod_prime5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f (m0,m1,m2,m3,1)))
(ensures (let r = carry_round5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let carry_round_after_last_carry_mod_prime5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in //(m0,m1,m2,m3,1)
let t1' = t1 +. (t0 >>. 52ul) in let t0' = t0 &. mask52 in
LD.lemma_carry52 m1 m0 t1 t0;
assert (felem_fits1 t1' (m1 + 1));
assert (felem_fits1 t0' 1);
assert (v t0' = v t0 % pow2 52);
assert (v t1' = v t1 + v t0 / pow2 52);
let t2' = t2 +. (t1' >>. 52ul) in let t1'' = t1' &. mask52 in
LD.lemma_carry52 m2 (m1 + 1) t2 t1';
assert (felem_fits1 t2' (m2 + 1));
assert (felem_fits1 t1'' 1);
assert (v t1'' = v t1' % pow2 52);
assert (v t2' = v t2 + v t1' / pow2 52);
let t3' = t3 +. (t2' >>. 52ul) in let t2'' = t2' &. mask52 in
LD.lemma_carry52 m3 (m2 + 1) t3 t2';
assert (felem_fits1 t3' (m3 + 1));
assert (felem_fits1 t2'' 1);
assert (v t2'' = v t2' % pow2 52);
assert (v t3' = v t3 + v t2' / pow2 52);
let t4' = t4 +. (t3' >>. 52ul) in let t3'' = t3' &. mask52 in
LD.lemma_carry_last52 m4 (m3 + 1) t4 t3';
assert (felem_fits_last1 t4' (m4 + 1));
assert (felem_fits1 t3'' 1);
assert (v t3'' = v t3' % pow2 52);
assert (v t4' = v t4 + v t3' / pow2 52);
LD.carry_last_small_mod_lemma t4 t3';
ML.lemma_simplify_carry_round (v t0) (v t1) (v t2) (v t3) (v t4);
let r = carry_round5 f in
assert ((t0',t1'',t2'',t3'',t4') == r);
assert (as_nat5 r == as_nat5 f)
val plus_x_mul_pow2_256_minus_prime_lemma: m:scale64_5 -> x:uint64 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f m /\ v x < pow2 16))
(ensures
(let r = plus_x_mul_pow2_256_minus_prime x f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime) /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let plus_x_mul_pow2_256_minus_prime_lemma m x f =
let (t0,t1,t2,t3,t4) = f in
let (m0,m1,m2,m3,m4) = m in
let t0' = t0 +. x *. u64 0x1000003D1 in
assert (v x < pow2 16);
Math.Lemmas.lemma_mult_lt_right 0x1000003D1 (v x) (pow2 16);
assert_norm (pow2 16 * 0x1000003D1 < max52);
assert (v t0 + v x * 0x1000003D1 < (m0 + 1) * max52);
Math.Lemmas.lemma_mult_le_right max52 (m0 + 1) 4096;
assert_norm (4096 * max52 < pow2 64);
Math.Lemmas.small_mod (v t0 + v x * 0x1000003D1) (pow2 64);
assert (v t0' = v t0 + v x * 0x1000003D1);
assert (felem_fits1 t0' (m0 + 1));
let r = carry_round5 (t0',t1,t2,t3,t4) in
carry_round_after_last_carry_mod_prime5_lemma (m0+1,m1,m2,m3,m4) (t0',t1,t2,t3,t4);
assert (as_nat5 r == as_nat5 (t0',t1,t2,t3,t4));
LD.lemma_pow2_256_minus_prime ();
assert (as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime))
val normalize_weak5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let r = normalize_weak5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f - v t4 / pow2 48 * S.prime /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let normalize_weak5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let x, f1 = minus_x_mul_pow2_256 f in
minus_x_mul_pow2_256_lemma m f;
assert (as_nat5 f1 == as_nat5 f - v x * pow2 256);
assert (felem_fits5 f1 (m0,m1,m2,m3,1));
let f2 = plus_x_mul_pow2_256_minus_prime x f1 in
plus_x_mul_pow2_256_minus_prime_lemma (m0,m1,m2,m3,1) x f1;
assert (as_nat5 f2 == as_nat5 f1 + v x * (pow2 256 - S.prime));
assert (felem_fits5 f2 (1,1,1,1,2));
assert (f2 == normalize_weak5 f);
Math.Lemmas.distributivity_sub_right (v x) (pow2 256) S.prime;
assert (as_nat5 f2 == as_nat5 f - v x * S.prime)
/// Normalize
#push-options "--ifuel 1"
val is_felem_ge_prime5_lemma: f:felem5 -> Lemma
(requires felem_fits5 f (1,1,1,1,1))
(ensures (let is_m = is_felem_ge_prime5 f in
(v is_m = 0 \/ v is_m = ones_v U64) /\
(if v is_m = ones_v U64 then (as_nat5 f >= S.prime) else (as_nat5 f < S.prime))))
let is_felem_ge_prime5_lemma f = ()
#pop-options
// let (f0,f1,f2,f3,f4) = f in
// let m4 = eq_mask f4 mask48 in
// eq_mask_lemma f4 mask48;
// assert (if v f4 = v mask48 then v m4 = ones_v U64 else v m4 = 0);
// let m3 = eq_mask f3 mask52 in
// eq_mask_lemma f3 mask52;
// assert (if v f3 = v mask52 then v m3 = ones_v U64 else v m3 = 0);
// let m2 = eq_mask f2 mask52 in
// eq_mask_lemma f2 mask52;
// assert (if v f2 = v mask52 then v m2 = ones_v U64 else v m2 = 0);
// let m1 = eq_mask f1 mask52 in
// eq_mask_lemma f1 mask52;
// assert (if v f1 = v mask52 then v m1 = ones_v U64 else v m1 = 0);
// let m0 = gte_mask f0 (u64 0xffffefffffc2f) in
// gte_mask_lemma f0 (u64 0xffffefffffc2f);
// assert (if v f0 >= 0xffffefffffc2f then v m0 = ones_v U64 else v m0 = 0);
// let m = m0 &. m1 &. m2 &. m3 &. m4 in ()
// if v m4 = 0 then
// logand_zeros (m0 &. m1 &. m2 &. m3)
// else begin
// logand_ones (m0 &. m1 &. m2 &. m3) end
noextract
let normalize5_first_part (f0,f1,f2,f3,f4) =
let (t0,t1,t2,t3,t4) = normalize_weak5 (f0,f1,f2,f3,f4) in
let x, (r0,r1,r2,r3,r4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
x, (r0,r1,r2,r3,r4)
noextract
let normalize5_second_part_x (x:uint64) (r0,r1,r2,r3,r4) : felem5 =
let is_ge_p_m = is_felem_ge_prime5 (r0,r1,r2,r3,r4) in // as_nat r >= S.prime
let m_to_one = is_ge_p_m &. u64 1 in
let x1 = m_to_one |. x in
let (s0,s1,s2,s3,s4) = plus_x_mul_pow2_256_minus_prime x1 (r0,r1,r2,r3,r4) in
let x2, (k0,k1,k2,k3,k4) = minus_x_mul_pow2_256 (s0,s1,s2,s3,s4) in
(k0,k1,k2,k3,k4)
val normalize5_first_part_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let x, r = normalize5_first_part f in
let (f0,f1,f2,f3,f4) = f in
let (r0,r1,r2,r3,r4) = r in
as_nat5 r == as_nat5 f - v f4 / pow2 48 * S.prime - v x * pow2 256 /\
felem_fits5 r (1,1,1,1,1) /\ (v x = 0 \/ (v x = 1 /\ v r4 < pow2 12))))
let normalize5_first_part_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (f0,f1,f2,f3,f4) = f in
let t = normalize_weak5 f in
let (t0,t1,t2,t3,t4) = t in
normalize_weak5_lemma m f;
assert (as_nat5 t == as_nat5 f - v f4 / pow2 48 * S.prime);
assert (felem_fits5 t (1,1,1,1,2));
assert ((v t4 >= pow2 48 ==> v t4 % pow2 48 < pow2 12));
let x, r = minus_x_mul_pow2_256 t in
let (r0,r1,r2,r3,r4) = r in
minus_x_mul_pow2_256_lemma (1,1,1,1,2) t;
assert (as_nat5 r == as_nat5 t - v x * pow2 256);
assert (as_nat5 r == as_nat5 f - v f4 / pow2 48 * S.prime - v x * pow2 256);
assert (felem_fits5 r (1,1,1,1,1));
assert (v r4 = v t4 % pow2 48 /\ v x = v t4 / pow2 48);
LD.lemma_div_pow48 t4;
assert (if v t4 < pow2 48 then v x = 0 else v x = 1 /\ v r4 < pow2 12)
val normalize5_second_part_x_is_one_lemma: x:uint64 -> r:felem5 -> Lemma
(requires (let (r0,r1,r2,r3,r4) = r in
felem_fits5 r (1,1,1,1,1) /\ v x = 1 /\ v r4 < pow2 12))
(ensures (let k = normalize5_second_part_x x r in
as_nat5 k == as_nat5 r + v x * pow2 256 - S.prime /\
felem_fits5 k (1,1,1,1,1) /\ as_nat5 k < S.prime))
let normalize5_second_part_x_is_one_lemma x r =
LD.lemma_as_nat_bound_f4_lt_pow12 r;
assert (as_nat5 r <= pow2 220 - 1);
assert_norm (pow2 220 - 1 < S.prime);
let is_ge_p_m = is_felem_ge_prime5 r in
is_felem_ge_prime5_lemma r;
assert (v is_ge_p_m = 0);
let m_to_one = is_ge_p_m &. u64 1 in
logand_lemma is_ge_p_m (u64 1);
assert (v m_to_one = 0);
let x1 = m_to_one |. x in //1
logor_spec m_to_one x;
FStar.UInt.logor_commutative #64 (v m_to_one) (v x);
FStar.UInt.logor_lemma_1 #64 (v x);
assert (v x1 = 1);
let s = plus_x_mul_pow2_256_minus_prime x1 r in // + x * (pow2 256 - S.prime)
plus_x_mul_pow2_256_minus_prime_lemma (1,1,1,1,1) x1 r;
assert (as_nat5 s = as_nat5 r + pow2 256 - S.prime); //(v s4 >= pow2 48 ==> v s4 % pow2 48 < pow2 12)
let (s0,s1,s2,s3,s4) = s in
Math.Lemmas.pow2_double_sum 12;
assert (v s4 < pow2 13);
let x2, k = minus_x_mul_pow2_256 s in // - s4 / pow2 48 * pow2 256
minus_x_mul_pow2_256_lemma (1,1,1,1,2) s;
assert (felem_fits5 k (1,1,1,1,1));
assert (as_nat5 k = as_nat5 s - v s4 / pow2 48 * pow2 256);
LD.lemma_div_pow48 s4;
assert (as_nat5 k = as_nat5 s);
assert (as_nat5 k < pow2 220 + pow2 256 - S.prime);
assert_norm (pow2 220 + pow2 256 - S.prime < S.prime)
val normalize5_second_part_x_is_zero_lemma: x:uint64 -> r:felem5 -> Lemma
(requires (let (r0,r1,r2,r3,r4) = r in
felem_fits5 r (1,1,1,1,1) /\ v x = 0))
(ensures (let k = normalize5_second_part_x x r in
as_nat5 k == (if as_nat5 r < S.prime then as_nat5 r else as_nat5 r - S.prime) /\
felem_fits5 k (1,1,1,1,1) /\ as_nat5 k < S.prime))
let normalize5_second_part_x_is_zero_lemma x r =
let is_ge_p_m = is_felem_ge_prime5 r in
is_felem_ge_prime5_lemma r;
assert (if v is_ge_p_m = ones_v U64
then (as_nat5 r >= S.prime) else as_nat5 r < S.prime);
let m_to_one = is_ge_p_m &. u64 1 in
logand_lemma is_ge_p_m (u64 1);
assert (if v is_ge_p_m = ones_v U64 then v m_to_one = 1 else v m_to_one = 0);
let x1 = m_to_one |. x in //1
logor_spec m_to_one x;
FStar.UInt.logor_lemma_1 #64 (v m_to_one);
assert (v x1 = v m_to_one);
assert (if v x1 = 1 then (as_nat5 r >= S.prime) else as_nat5 r < S.prime);
let s = plus_x_mul_pow2_256_minus_prime x1 r in // + x1 * (pow2 256 - S.prime)
plus_x_mul_pow2_256_minus_prime_lemma (1,1,1,1,1) x1 r;
assert (as_nat5 s = as_nat5 r + v x1 * (pow2 256 - S.prime)); //(v s4 >= pow2 48 ==> v s4 % pow2 48 < pow2 12)
let (s0,s1,s2,s3,s4) = s in
let x2, k = minus_x_mul_pow2_256 s in // - s4 / pow2 48 * pow2 256
minus_x_mul_pow2_256_lemma (1,1,1,1,2) s;
assert (felem_fits5 k (1,1,1,1,1));
assert (as_nat5 k = as_nat5 s - v s4 / pow2 48 * pow2 256);
if v x1 = 0 then begin
assert (as_nat5 s = as_nat5 r);
LD.as_nat_inj s r;
assert (felem_fits_last1 s4 1);
Math.Lemmas.small_div (v s4) (pow2 48);
assert (as_nat5 k = as_nat5 r) end
else begin
assert (as_nat5 s = as_nat5 r + pow2 256 - S.prime);
assert (as_nat5 s >= pow2 256);
assert (v s4 >= pow2 48);
LD.lemma_div_pow48 s4;
assert (as_nat5 k = as_nat5 r - S.prime) end
val lemma_a_minus_b_n_c_n_k (k a b c:nat) (n:pos) : Lemma
(requires k < n /\ k == a - b * n - c * n)
(ensures k == a % n) | false | false | Hacl.Spec.K256.Field52.Lemmas2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_a_minus_b_n_c_n_k (k a b c:nat) (n:pos) : Lemma
(requires k < n /\ k == a - b * n - c * n)
(ensures k == a % n) | [] | Hacl.Spec.K256.Field52.Lemmas2.lemma_a_minus_b_n_c_n_k | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.Lemmas2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | k: Prims.nat -> a: Prims.nat -> b: Prims.nat -> c: Prims.nat -> n: Prims.pos
-> FStar.Pervasives.Lemma (requires k < n /\ k == a - b * n - c * n) (ensures k == a % n) | {
"end_col": 27,
"end_line": 352,
"start_col": 2,
"start_line": 350
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Definitions.Lemmas",
"short_module": "LD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.MathLemmas",
"short_module": "ML"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let normalize5_second_part_x (x:uint64) (r0,r1,r2,r3,r4) : felem5 =
let is_ge_p_m = is_felem_ge_prime5 (r0,r1,r2,r3,r4) in // as_nat r >= S.prime
let m_to_one = is_ge_p_m &. u64 1 in
let x1 = m_to_one |. x in
let (s0,s1,s2,s3,s4) = plus_x_mul_pow2_256_minus_prime x1 (r0,r1,r2,r3,r4) in
let x2, (k0,k1,k2,k3,k4) = minus_x_mul_pow2_256 (s0,s1,s2,s3,s4) in
(k0,k1,k2,k3,k4) | let normalize5_second_part_x (x: uint64) (r0, r1, r2, r3, r4) : felem5 = | false | null | false | let is_ge_p_m = is_felem_ge_prime5 (r0, r1, r2, r3, r4) in
let m_to_one = is_ge_p_m &. u64 1 in
let x1 = m_to_one |. x in
let s0, s1, s2, s3, s4 = plus_x_mul_pow2_256_minus_prime x1 (r0, r1, r2, r3, r4) in
let x2, (k0, k1, k2, k3, k4) = minus_x_mul_pow2_256 (s0, s1, s2, s3, s4) in
(k0, k1, k2, k3, k4) | {
"checked_file": "Hacl.Spec.K256.Field52.Lemmas2.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.MathLemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.Lemmas2.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.tuple5",
"FStar.Pervasives.Native.Mktuple5",
"Hacl.Spec.K256.Field52.Definitions.felem5",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Spec.K256.Field52.minus_x_mul_pow2_256",
"Hacl.Spec.K256.Field52.plus_x_mul_pow2_256_minus_prime",
"Lib.IntTypes.op_Bar_Dot",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.u64",
"Hacl.Spec.K256.Field52.is_felem_ge_prime5"
] | [] | module Hacl.Spec.K256.Field52.Lemmas2
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
include Hacl.Spec.K256.Field52
module ML = Hacl.Spec.K256.MathLemmas
module LD = Hacl.Spec.K256.Field52.Definitions.Lemmas
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
/// Normalize-weak
val minus_x_mul_pow2_256_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires felem_fits5 f m)
(ensures
(let x, r = minus_x_mul_pow2_256 f in
let (r0,r1,r2,r3,r4) = r in
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
v x < pow2 16 /\ v x = v t4 / pow2 48 /\
v r4 = v t4 % pow2 48 /\
as_nat5 r == as_nat5 f - v x * pow2 256 /\
felem_fits5 r (m0,m1,m2,m3,1)))
let minus_x_mul_pow2_256_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
let x = t4 >>. 48ul in let t4' = t4 &. mask48 in
LD.lemma_mask48 t4;
let r = (t0,t1,t2,t3,t4') in
calc (==) { // as_nat5 f
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + v t4 * pow208;
(==) { Math.Lemmas.euclidean_division_definition (v t4) (pow2 48) }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48 + v t4 % pow2 48) * pow208;
(==) { Math.Lemmas.distributivity_add_left (v t4 / pow2 48 * pow2 48) (v t4 % pow2 48) pow208 }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48) * pow208 + (v t4 % pow2 48) * pow208;
(==) { }
(v x * pow2 48) * pow208 + as_nat5 r;
(==) { Math.Lemmas.paren_mul_right (v x) (pow2 48) pow208; Math.Lemmas.pow2_plus 48 208 }
v x * pow2 256 + as_nat5 r;
};
Math.Lemmas.lemma_div_lt (v t4) 64 48
val carry_round_after_last_carry_mod_prime5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f (m0,m1,m2,m3,1)))
(ensures (let r = carry_round5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let carry_round_after_last_carry_mod_prime5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in //(m0,m1,m2,m3,1)
let t1' = t1 +. (t0 >>. 52ul) in let t0' = t0 &. mask52 in
LD.lemma_carry52 m1 m0 t1 t0;
assert (felem_fits1 t1' (m1 + 1));
assert (felem_fits1 t0' 1);
assert (v t0' = v t0 % pow2 52);
assert (v t1' = v t1 + v t0 / pow2 52);
let t2' = t2 +. (t1' >>. 52ul) in let t1'' = t1' &. mask52 in
LD.lemma_carry52 m2 (m1 + 1) t2 t1';
assert (felem_fits1 t2' (m2 + 1));
assert (felem_fits1 t1'' 1);
assert (v t1'' = v t1' % pow2 52);
assert (v t2' = v t2 + v t1' / pow2 52);
let t3' = t3 +. (t2' >>. 52ul) in let t2'' = t2' &. mask52 in
LD.lemma_carry52 m3 (m2 + 1) t3 t2';
assert (felem_fits1 t3' (m3 + 1));
assert (felem_fits1 t2'' 1);
assert (v t2'' = v t2' % pow2 52);
assert (v t3' = v t3 + v t2' / pow2 52);
let t4' = t4 +. (t3' >>. 52ul) in let t3'' = t3' &. mask52 in
LD.lemma_carry_last52 m4 (m3 + 1) t4 t3';
assert (felem_fits_last1 t4' (m4 + 1));
assert (felem_fits1 t3'' 1);
assert (v t3'' = v t3' % pow2 52);
assert (v t4' = v t4 + v t3' / pow2 52);
LD.carry_last_small_mod_lemma t4 t3';
ML.lemma_simplify_carry_round (v t0) (v t1) (v t2) (v t3) (v t4);
let r = carry_round5 f in
assert ((t0',t1'',t2'',t3'',t4') == r);
assert (as_nat5 r == as_nat5 f)
val plus_x_mul_pow2_256_minus_prime_lemma: m:scale64_5 -> x:uint64 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f m /\ v x < pow2 16))
(ensures
(let r = plus_x_mul_pow2_256_minus_prime x f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime) /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let plus_x_mul_pow2_256_minus_prime_lemma m x f =
let (t0,t1,t2,t3,t4) = f in
let (m0,m1,m2,m3,m4) = m in
let t0' = t0 +. x *. u64 0x1000003D1 in
assert (v x < pow2 16);
Math.Lemmas.lemma_mult_lt_right 0x1000003D1 (v x) (pow2 16);
assert_norm (pow2 16 * 0x1000003D1 < max52);
assert (v t0 + v x * 0x1000003D1 < (m0 + 1) * max52);
Math.Lemmas.lemma_mult_le_right max52 (m0 + 1) 4096;
assert_norm (4096 * max52 < pow2 64);
Math.Lemmas.small_mod (v t0 + v x * 0x1000003D1) (pow2 64);
assert (v t0' = v t0 + v x * 0x1000003D1);
assert (felem_fits1 t0' (m0 + 1));
let r = carry_round5 (t0',t1,t2,t3,t4) in
carry_round_after_last_carry_mod_prime5_lemma (m0+1,m1,m2,m3,m4) (t0',t1,t2,t3,t4);
assert (as_nat5 r == as_nat5 (t0',t1,t2,t3,t4));
LD.lemma_pow2_256_minus_prime ();
assert (as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime))
val normalize_weak5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let r = normalize_weak5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f - v t4 / pow2 48 * S.prime /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let normalize_weak5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let x, f1 = minus_x_mul_pow2_256 f in
minus_x_mul_pow2_256_lemma m f;
assert (as_nat5 f1 == as_nat5 f - v x * pow2 256);
assert (felem_fits5 f1 (m0,m1,m2,m3,1));
let f2 = plus_x_mul_pow2_256_minus_prime x f1 in
plus_x_mul_pow2_256_minus_prime_lemma (m0,m1,m2,m3,1) x f1;
assert (as_nat5 f2 == as_nat5 f1 + v x * (pow2 256 - S.prime));
assert (felem_fits5 f2 (1,1,1,1,2));
assert (f2 == normalize_weak5 f);
Math.Lemmas.distributivity_sub_right (v x) (pow2 256) S.prime;
assert (as_nat5 f2 == as_nat5 f - v x * S.prime)
/// Normalize
#push-options "--ifuel 1"
val is_felem_ge_prime5_lemma: f:felem5 -> Lemma
(requires felem_fits5 f (1,1,1,1,1))
(ensures (let is_m = is_felem_ge_prime5 f in
(v is_m = 0 \/ v is_m = ones_v U64) /\
(if v is_m = ones_v U64 then (as_nat5 f >= S.prime) else (as_nat5 f < S.prime))))
let is_felem_ge_prime5_lemma f = ()
#pop-options
// let (f0,f1,f2,f3,f4) = f in
// let m4 = eq_mask f4 mask48 in
// eq_mask_lemma f4 mask48;
// assert (if v f4 = v mask48 then v m4 = ones_v U64 else v m4 = 0);
// let m3 = eq_mask f3 mask52 in
// eq_mask_lemma f3 mask52;
// assert (if v f3 = v mask52 then v m3 = ones_v U64 else v m3 = 0);
// let m2 = eq_mask f2 mask52 in
// eq_mask_lemma f2 mask52;
// assert (if v f2 = v mask52 then v m2 = ones_v U64 else v m2 = 0);
// let m1 = eq_mask f1 mask52 in
// eq_mask_lemma f1 mask52;
// assert (if v f1 = v mask52 then v m1 = ones_v U64 else v m1 = 0);
// let m0 = gte_mask f0 (u64 0xffffefffffc2f) in
// gte_mask_lemma f0 (u64 0xffffefffffc2f);
// assert (if v f0 >= 0xffffefffffc2f then v m0 = ones_v U64 else v m0 = 0);
// let m = m0 &. m1 &. m2 &. m3 &. m4 in ()
// if v m4 = 0 then
// logand_zeros (m0 &. m1 &. m2 &. m3)
// else begin
// logand_ones (m0 &. m1 &. m2 &. m3) end
noextract
let normalize5_first_part (f0,f1,f2,f3,f4) =
let (t0,t1,t2,t3,t4) = normalize_weak5 (f0,f1,f2,f3,f4) in
let x, (r0,r1,r2,r3,r4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
x, (r0,r1,r2,r3,r4) | false | true | Hacl.Spec.K256.Field52.Lemmas2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val normalize5_second_part_x : x: Lib.IntTypes.uint64 ->
_:
((((Lib.IntTypes.uint64 * Lib.IntTypes.uint64) * Lib.IntTypes.uint64) * Lib.IntTypes.uint64) *
Lib.IntTypes.uint64)
-> Hacl.Spec.K256.Field52.Definitions.felem5 | [] | Hacl.Spec.K256.Field52.Lemmas2.normalize5_second_part_x | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.Lemmas2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
x: Lib.IntTypes.uint64 ->
_:
((((Lib.IntTypes.uint64 * Lib.IntTypes.uint64) * Lib.IntTypes.uint64) * Lib.IntTypes.uint64) *
Lib.IntTypes.uint64)
-> Hacl.Spec.K256.Field52.Definitions.felem5 | {
"end_col": 18,
"end_line": 217,
"start_col": 67,
"start_line": 211
} |
|
FStar.Pervasives.Lemma | val normalize_weak5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let r = normalize_weak5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f - v t4 / pow2 48 * S.prime /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12))) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Definitions.Lemmas",
"short_module": "LD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.MathLemmas",
"short_module": "ML"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let normalize_weak5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let x, f1 = minus_x_mul_pow2_256 f in
minus_x_mul_pow2_256_lemma m f;
assert (as_nat5 f1 == as_nat5 f - v x * pow2 256);
assert (felem_fits5 f1 (m0,m1,m2,m3,1));
let f2 = plus_x_mul_pow2_256_minus_prime x f1 in
plus_x_mul_pow2_256_minus_prime_lemma (m0,m1,m2,m3,1) x f1;
assert (as_nat5 f2 == as_nat5 f1 + v x * (pow2 256 - S.prime));
assert (felem_fits5 f2 (1,1,1,1,2));
assert (f2 == normalize_weak5 f);
Math.Lemmas.distributivity_sub_right (v x) (pow2 256) S.prime;
assert (as_nat5 f2 == as_nat5 f - v x * S.prime) | val normalize_weak5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let r = normalize_weak5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f - v t4 / pow2 48 * S.prime /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let normalize_weak5_lemma m f = | false | null | true | let m0, m1, m2, m3, m4 = m in
let x, f1 = minus_x_mul_pow2_256 f in
minus_x_mul_pow2_256_lemma m f;
assert (as_nat5 f1 == as_nat5 f - v x * pow2 256);
assert (felem_fits5 f1 (m0, m1, m2, m3, 1));
let f2 = plus_x_mul_pow2_256_minus_prime x f1 in
plus_x_mul_pow2_256_minus_prime_lemma (m0, m1, m2, m3, 1) x f1;
assert (as_nat5 f2 == as_nat5 f1 + v x * (pow2 256 - S.prime));
assert (felem_fits5 f2 (1, 1, 1, 1, 2));
assert (f2 == normalize_weak5 f);
Math.Lemmas.distributivity_sub_right (v x) (pow2 256) S.prime;
assert (as_nat5 f2 == as_nat5 f - v x * S.prime) | {
"checked_file": "Hacl.Spec.K256.Field52.Lemmas2.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.MathLemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.Lemmas2.fst"
} | [
"lemma"
] | [
"Hacl.Spec.K256.Field52.Definitions.scale64_5",
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Prims.nat",
"Lib.IntTypes.uint64",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Hacl.Spec.K256.Field52.Definitions.as_nat5",
"Prims.op_Subtraction",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Spec.K256.PointOps.prime",
"Prims.unit",
"FStar.Math.Lemmas.distributivity_sub_right",
"Prims.pow2",
"Hacl.Spec.K256.Field52.normalize_weak5",
"Hacl.Spec.K256.Field52.Definitions.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.op_Addition",
"Hacl.Spec.K256.Field52.Lemmas2.plus_x_mul_pow2_256_minus_prime_lemma",
"Hacl.Spec.K256.Field52.plus_x_mul_pow2_256_minus_prime",
"Hacl.Spec.K256.Field52.Lemmas2.minus_x_mul_pow2_256_lemma",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Hacl.Spec.K256.Field52.minus_x_mul_pow2_256"
] | [] | module Hacl.Spec.K256.Field52.Lemmas2
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
include Hacl.Spec.K256.Field52
module ML = Hacl.Spec.K256.MathLemmas
module LD = Hacl.Spec.K256.Field52.Definitions.Lemmas
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
/// Normalize-weak
val minus_x_mul_pow2_256_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires felem_fits5 f m)
(ensures
(let x, r = minus_x_mul_pow2_256 f in
let (r0,r1,r2,r3,r4) = r in
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
v x < pow2 16 /\ v x = v t4 / pow2 48 /\
v r4 = v t4 % pow2 48 /\
as_nat5 r == as_nat5 f - v x * pow2 256 /\
felem_fits5 r (m0,m1,m2,m3,1)))
let minus_x_mul_pow2_256_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
let x = t4 >>. 48ul in let t4' = t4 &. mask48 in
LD.lemma_mask48 t4;
let r = (t0,t1,t2,t3,t4') in
calc (==) { // as_nat5 f
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + v t4 * pow208;
(==) { Math.Lemmas.euclidean_division_definition (v t4) (pow2 48) }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48 + v t4 % pow2 48) * pow208;
(==) { Math.Lemmas.distributivity_add_left (v t4 / pow2 48 * pow2 48) (v t4 % pow2 48) pow208 }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48) * pow208 + (v t4 % pow2 48) * pow208;
(==) { }
(v x * pow2 48) * pow208 + as_nat5 r;
(==) { Math.Lemmas.paren_mul_right (v x) (pow2 48) pow208; Math.Lemmas.pow2_plus 48 208 }
v x * pow2 256 + as_nat5 r;
};
Math.Lemmas.lemma_div_lt (v t4) 64 48
val carry_round_after_last_carry_mod_prime5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f (m0,m1,m2,m3,1)))
(ensures (let r = carry_round5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let carry_round_after_last_carry_mod_prime5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in //(m0,m1,m2,m3,1)
let t1' = t1 +. (t0 >>. 52ul) in let t0' = t0 &. mask52 in
LD.lemma_carry52 m1 m0 t1 t0;
assert (felem_fits1 t1' (m1 + 1));
assert (felem_fits1 t0' 1);
assert (v t0' = v t0 % pow2 52);
assert (v t1' = v t1 + v t0 / pow2 52);
let t2' = t2 +. (t1' >>. 52ul) in let t1'' = t1' &. mask52 in
LD.lemma_carry52 m2 (m1 + 1) t2 t1';
assert (felem_fits1 t2' (m2 + 1));
assert (felem_fits1 t1'' 1);
assert (v t1'' = v t1' % pow2 52);
assert (v t2' = v t2 + v t1' / pow2 52);
let t3' = t3 +. (t2' >>. 52ul) in let t2'' = t2' &. mask52 in
LD.lemma_carry52 m3 (m2 + 1) t3 t2';
assert (felem_fits1 t3' (m3 + 1));
assert (felem_fits1 t2'' 1);
assert (v t2'' = v t2' % pow2 52);
assert (v t3' = v t3 + v t2' / pow2 52);
let t4' = t4 +. (t3' >>. 52ul) in let t3'' = t3' &. mask52 in
LD.lemma_carry_last52 m4 (m3 + 1) t4 t3';
assert (felem_fits_last1 t4' (m4 + 1));
assert (felem_fits1 t3'' 1);
assert (v t3'' = v t3' % pow2 52);
assert (v t4' = v t4 + v t3' / pow2 52);
LD.carry_last_small_mod_lemma t4 t3';
ML.lemma_simplify_carry_round (v t0) (v t1) (v t2) (v t3) (v t4);
let r = carry_round5 f in
assert ((t0',t1'',t2'',t3'',t4') == r);
assert (as_nat5 r == as_nat5 f)
val plus_x_mul_pow2_256_minus_prime_lemma: m:scale64_5 -> x:uint64 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f m /\ v x < pow2 16))
(ensures
(let r = plus_x_mul_pow2_256_minus_prime x f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime) /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let plus_x_mul_pow2_256_minus_prime_lemma m x f =
let (t0,t1,t2,t3,t4) = f in
let (m0,m1,m2,m3,m4) = m in
let t0' = t0 +. x *. u64 0x1000003D1 in
assert (v x < pow2 16);
Math.Lemmas.lemma_mult_lt_right 0x1000003D1 (v x) (pow2 16);
assert_norm (pow2 16 * 0x1000003D1 < max52);
assert (v t0 + v x * 0x1000003D1 < (m0 + 1) * max52);
Math.Lemmas.lemma_mult_le_right max52 (m0 + 1) 4096;
assert_norm (4096 * max52 < pow2 64);
Math.Lemmas.small_mod (v t0 + v x * 0x1000003D1) (pow2 64);
assert (v t0' = v t0 + v x * 0x1000003D1);
assert (felem_fits1 t0' (m0 + 1));
let r = carry_round5 (t0',t1,t2,t3,t4) in
carry_round_after_last_carry_mod_prime5_lemma (m0+1,m1,m2,m3,m4) (t0',t1,t2,t3,t4);
assert (as_nat5 r == as_nat5 (t0',t1,t2,t3,t4));
LD.lemma_pow2_256_minus_prime ();
assert (as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime))
val normalize_weak5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let r = normalize_weak5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f - v t4 / pow2 48 * S.prime /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12))) | false | false | Hacl.Spec.K256.Field52.Lemmas2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val normalize_weak5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let r = normalize_weak5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f - v t4 / pow2 48 * S.prime /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12))) | [] | Hacl.Spec.K256.Field52.Lemmas2.normalize_weak5_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.Lemmas2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | m: Hacl.Spec.K256.Field52.Definitions.scale64_5 -> f: Hacl.Spec.K256.Field52.Definitions.felem5
-> FStar.Pervasives.Lemma
(requires
(let _ = m in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ m0 m1 m2 m3 _ = _ in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
Hacl.Spec.K256.Field52.Definitions.felem_fits5 f m)
<:
Type0))
(ensures
(let r = Hacl.Spec.K256.Field52.normalize_weak5 f in
let _ = r in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ r4 = _ in
let _ = f in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ t4 = _ in
Hacl.Spec.K256.Field52.Definitions.as_nat5 r ==
Hacl.Spec.K256.Field52.Definitions.as_nat5 f -
(Lib.IntTypes.v t4 / Prims.pow2 48) * Spec.K256.PointOps.prime /\
Hacl.Spec.K256.Field52.Definitions.felem_fits5 r (1, 1, 1, 1, 2) /\
Lib.IntTypes.v r4 < Lib.IntTypes.v t4 + Prims.pow2 12 /\
(Lib.IntTypes.v r4 >= Prims.pow2 48 ==>
Lib.IntTypes.v r4 % Prims.pow2 48 < Prims.pow2 12))
<:
Type0)
<:
Type0)) | {
"end_col": 50,
"end_line": 162,
"start_col": 31,
"start_line": 148
} |
FStar.Pervasives.Lemma | val carry_round_after_last_carry_mod_prime5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f (m0,m1,m2,m3,1)))
(ensures (let r = carry_round5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12))) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Definitions.Lemmas",
"short_module": "LD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.MathLemmas",
"short_module": "ML"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let carry_round_after_last_carry_mod_prime5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in //(m0,m1,m2,m3,1)
let t1' = t1 +. (t0 >>. 52ul) in let t0' = t0 &. mask52 in
LD.lemma_carry52 m1 m0 t1 t0;
assert (felem_fits1 t1' (m1 + 1));
assert (felem_fits1 t0' 1);
assert (v t0' = v t0 % pow2 52);
assert (v t1' = v t1 + v t0 / pow2 52);
let t2' = t2 +. (t1' >>. 52ul) in let t1'' = t1' &. mask52 in
LD.lemma_carry52 m2 (m1 + 1) t2 t1';
assert (felem_fits1 t2' (m2 + 1));
assert (felem_fits1 t1'' 1);
assert (v t1'' = v t1' % pow2 52);
assert (v t2' = v t2 + v t1' / pow2 52);
let t3' = t3 +. (t2' >>. 52ul) in let t2'' = t2' &. mask52 in
LD.lemma_carry52 m3 (m2 + 1) t3 t2';
assert (felem_fits1 t3' (m3 + 1));
assert (felem_fits1 t2'' 1);
assert (v t2'' = v t2' % pow2 52);
assert (v t3' = v t3 + v t2' / pow2 52);
let t4' = t4 +. (t3' >>. 52ul) in let t3'' = t3' &. mask52 in
LD.lemma_carry_last52 m4 (m3 + 1) t4 t3';
assert (felem_fits_last1 t4' (m4 + 1));
assert (felem_fits1 t3'' 1);
assert (v t3'' = v t3' % pow2 52);
assert (v t4' = v t4 + v t3' / pow2 52);
LD.carry_last_small_mod_lemma t4 t3';
ML.lemma_simplify_carry_round (v t0) (v t1) (v t2) (v t3) (v t4);
let r = carry_round5 f in
assert ((t0',t1'',t2'',t3'',t4') == r);
assert (as_nat5 r == as_nat5 f) | val carry_round_after_last_carry_mod_prime5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f (m0,m1,m2,m3,1)))
(ensures (let r = carry_round5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let carry_round_after_last_carry_mod_prime5_lemma m f = | false | null | true | let m0, m1, m2, m3, m4 = m in
let t0, t1, t2, t3, t4 = f in
let t1' = t1 +. (t0 >>. 52ul) in
let t0' = t0 &. mask52 in
LD.lemma_carry52 m1 m0 t1 t0;
assert (felem_fits1 t1' (m1 + 1));
assert (felem_fits1 t0' 1);
assert (v t0' = v t0 % pow2 52);
assert (v t1' = v t1 + v t0 / pow2 52);
let t2' = t2 +. (t1' >>. 52ul) in
let t1'' = t1' &. mask52 in
LD.lemma_carry52 m2 (m1 + 1) t2 t1';
assert (felem_fits1 t2' (m2 + 1));
assert (felem_fits1 t1'' 1);
assert (v t1'' = v t1' % pow2 52);
assert (v t2' = v t2 + v t1' / pow2 52);
let t3' = t3 +. (t2' >>. 52ul) in
let t2'' = t2' &. mask52 in
LD.lemma_carry52 m3 (m2 + 1) t3 t2';
assert (felem_fits1 t3' (m3 + 1));
assert (felem_fits1 t2'' 1);
assert (v t2'' = v t2' % pow2 52);
assert (v t3' = v t3 + v t2' / pow2 52);
let t4' = t4 +. (t3' >>. 52ul) in
let t3'' = t3' &. mask52 in
LD.lemma_carry_last52 m4 (m3 + 1) t4 t3';
assert (felem_fits_last1 t4' (m4 + 1));
assert (felem_fits1 t3'' 1);
assert (v t3'' = v t3' % pow2 52);
assert (v t4' = v t4 + v t3' / pow2 52);
LD.carry_last_small_mod_lemma t4 t3';
ML.lemma_simplify_carry_round (v t0) (v t1) (v t2) (v t3) (v t4);
let r = carry_round5 f in
assert ((t0', t1'', t2'', t3'', t4') == r);
assert (as_nat5 r == as_nat5 f) | {
"checked_file": "Hacl.Spec.K256.Field52.Lemmas2.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.MathLemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.Lemmas2.fst"
} | [
"lemma"
] | [
"Hacl.Spec.K256.Field52.Definitions.scale64_5",
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Prims.nat",
"Lib.IntTypes.uint64",
"Prims._assert",
"Prims.eq2",
"Hacl.Spec.K256.Field52.Definitions.as_nat5",
"Prims.unit",
"FStar.Pervasives.Native.tuple5",
"FStar.Pervasives.Native.Mktuple5",
"Hacl.Spec.K256.Field52.carry_round5",
"Hacl.Spec.K256.MathLemmas.lemma_simplify_carry_round",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.carry_last_small_mod_lemma",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Addition",
"Prims.op_Division",
"Prims.pow2",
"Prims.op_Modulus",
"Hacl.Spec.K256.Field52.Definitions.felem_fits1",
"Hacl.Spec.K256.Field52.Definitions.felem_fits_last1",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.lemma_carry_last52",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Amp_Dot",
"Hacl.Spec.K256.Field52.Definitions.mask52",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.op_Greater_Greater_Dot",
"FStar.UInt32.__uint_to_t",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.lemma_carry52"
] | [] | module Hacl.Spec.K256.Field52.Lemmas2
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
include Hacl.Spec.K256.Field52
module ML = Hacl.Spec.K256.MathLemmas
module LD = Hacl.Spec.K256.Field52.Definitions.Lemmas
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
/// Normalize-weak
val minus_x_mul_pow2_256_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires felem_fits5 f m)
(ensures
(let x, r = minus_x_mul_pow2_256 f in
let (r0,r1,r2,r3,r4) = r in
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
v x < pow2 16 /\ v x = v t4 / pow2 48 /\
v r4 = v t4 % pow2 48 /\
as_nat5 r == as_nat5 f - v x * pow2 256 /\
felem_fits5 r (m0,m1,m2,m3,1)))
let minus_x_mul_pow2_256_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
let x = t4 >>. 48ul in let t4' = t4 &. mask48 in
LD.lemma_mask48 t4;
let r = (t0,t1,t2,t3,t4') in
calc (==) { // as_nat5 f
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + v t4 * pow208;
(==) { Math.Lemmas.euclidean_division_definition (v t4) (pow2 48) }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48 + v t4 % pow2 48) * pow208;
(==) { Math.Lemmas.distributivity_add_left (v t4 / pow2 48 * pow2 48) (v t4 % pow2 48) pow208 }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48) * pow208 + (v t4 % pow2 48) * pow208;
(==) { }
(v x * pow2 48) * pow208 + as_nat5 r;
(==) { Math.Lemmas.paren_mul_right (v x) (pow2 48) pow208; Math.Lemmas.pow2_plus 48 208 }
v x * pow2 256 + as_nat5 r;
};
Math.Lemmas.lemma_div_lt (v t4) 64 48
val carry_round_after_last_carry_mod_prime5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f (m0,m1,m2,m3,1)))
(ensures (let r = carry_round5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12))) | false | false | Hacl.Spec.K256.Field52.Lemmas2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val carry_round_after_last_carry_mod_prime5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f (m0,m1,m2,m3,1)))
(ensures (let r = carry_round5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12))) | [] | Hacl.Spec.K256.Field52.Lemmas2.carry_round_after_last_carry_mod_prime5_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.Lemmas2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | m: Hacl.Spec.K256.Field52.Definitions.scale64_5 -> f: Hacl.Spec.K256.Field52.Definitions.felem5
-> FStar.Pervasives.Lemma
(requires
(let _ = m in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ m0 m1 m2 m3 m4 = _ in
m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
Hacl.Spec.K256.Field52.Definitions.felem_fits5 f (m0, m1, m2, m3, 1))
<:
Type0))
(ensures
(let r = Hacl.Spec.K256.Field52.carry_round5 f in
let _ = r in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ r4 = _ in
let _ = f in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ t4 = _ in
Hacl.Spec.K256.Field52.Definitions.as_nat5 r ==
Hacl.Spec.K256.Field52.Definitions.as_nat5 f /\
Hacl.Spec.K256.Field52.Definitions.felem_fits5 r (1, 1, 1, 1, 2) /\
Lib.IntTypes.v r4 < Lib.IntTypes.v t4 + Prims.pow2 12 /\
(Lib.IntTypes.v r4 >= Prims.pow2 48 ==>
Lib.IntTypes.v r4 % Prims.pow2 48 < Prims.pow2 12))
<:
Type0)
<:
Type0)) | {
"end_col": 33,
"end_line": 99,
"start_col": 55,
"start_line": 63
} |
FStar.Pervasives.Lemma | val normalize5_second_part_x_is_one_lemma: x:uint64 -> r:felem5 -> Lemma
(requires (let (r0,r1,r2,r3,r4) = r in
felem_fits5 r (1,1,1,1,1) /\ v x = 1 /\ v r4 < pow2 12))
(ensures (let k = normalize5_second_part_x x r in
as_nat5 k == as_nat5 r + v x * pow2 256 - S.prime /\
felem_fits5 k (1,1,1,1,1) /\ as_nat5 k < S.prime)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Definitions.Lemmas",
"short_module": "LD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.MathLemmas",
"short_module": "ML"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let normalize5_second_part_x_is_one_lemma x r =
LD.lemma_as_nat_bound_f4_lt_pow12 r;
assert (as_nat5 r <= pow2 220 - 1);
assert_norm (pow2 220 - 1 < S.prime);
let is_ge_p_m = is_felem_ge_prime5 r in
is_felem_ge_prime5_lemma r;
assert (v is_ge_p_m = 0);
let m_to_one = is_ge_p_m &. u64 1 in
logand_lemma is_ge_p_m (u64 1);
assert (v m_to_one = 0);
let x1 = m_to_one |. x in //1
logor_spec m_to_one x;
FStar.UInt.logor_commutative #64 (v m_to_one) (v x);
FStar.UInt.logor_lemma_1 #64 (v x);
assert (v x1 = 1);
let s = plus_x_mul_pow2_256_minus_prime x1 r in // + x * (pow2 256 - S.prime)
plus_x_mul_pow2_256_minus_prime_lemma (1,1,1,1,1) x1 r;
assert (as_nat5 s = as_nat5 r + pow2 256 - S.prime); //(v s4 >= pow2 48 ==> v s4 % pow2 48 < pow2 12)
let (s0,s1,s2,s3,s4) = s in
Math.Lemmas.pow2_double_sum 12;
assert (v s4 < pow2 13);
let x2, k = minus_x_mul_pow2_256 s in // - s4 / pow2 48 * pow2 256
minus_x_mul_pow2_256_lemma (1,1,1,1,2) s;
assert (felem_fits5 k (1,1,1,1,1));
assert (as_nat5 k = as_nat5 s - v s4 / pow2 48 * pow2 256);
LD.lemma_div_pow48 s4;
assert (as_nat5 k = as_nat5 s);
assert (as_nat5 k < pow2 220 + pow2 256 - S.prime);
assert_norm (pow2 220 + pow2 256 - S.prime < S.prime) | val normalize5_second_part_x_is_one_lemma: x:uint64 -> r:felem5 -> Lemma
(requires (let (r0,r1,r2,r3,r4) = r in
felem_fits5 r (1,1,1,1,1) /\ v x = 1 /\ v r4 < pow2 12))
(ensures (let k = normalize5_second_part_x x r in
as_nat5 k == as_nat5 r + v x * pow2 256 - S.prime /\
felem_fits5 k (1,1,1,1,1) /\ as_nat5 k < S.prime))
let normalize5_second_part_x_is_one_lemma x r = | false | null | true | LD.lemma_as_nat_bound_f4_lt_pow12 r;
assert (as_nat5 r <= pow2 220 - 1);
assert_norm (pow2 220 - 1 < S.prime);
let is_ge_p_m = is_felem_ge_prime5 r in
is_felem_ge_prime5_lemma r;
assert (v is_ge_p_m = 0);
let m_to_one = is_ge_p_m &. u64 1 in
logand_lemma is_ge_p_m (u64 1);
assert (v m_to_one = 0);
let x1 = m_to_one |. x in
logor_spec m_to_one x;
FStar.UInt.logor_commutative #64 (v m_to_one) (v x);
FStar.UInt.logor_lemma_1 #64 (v x);
assert (v x1 = 1);
let s = plus_x_mul_pow2_256_minus_prime x1 r in
plus_x_mul_pow2_256_minus_prime_lemma (1, 1, 1, 1, 1) x1 r;
assert (as_nat5 s = as_nat5 r + pow2 256 - S.prime);
let s0, s1, s2, s3, s4 = s in
Math.Lemmas.pow2_double_sum 12;
assert (v s4 < pow2 13);
let x2, k = minus_x_mul_pow2_256 s in
minus_x_mul_pow2_256_lemma (1, 1, 1, 1, 2) s;
assert (felem_fits5 k (1, 1, 1, 1, 1));
assert (as_nat5 k = as_nat5 s - (v s4 / pow2 48) * pow2 256);
LD.lemma_div_pow48 s4;
assert (as_nat5 k = as_nat5 s);
assert (as_nat5 k < pow2 220 + pow2 256 - S.prime);
assert_norm (pow2 220 + pow2 256 - S.prime < S.prime) | {
"checked_file": "Hacl.Spec.K256.Field52.Lemmas2.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.MathLemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.Lemmas2.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.uint64",
"Hacl.Spec.K256.Field52.Definitions.felem5",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Subtraction",
"Prims.op_Addition",
"Prims.pow2",
"Spec.K256.PointOps.prime",
"Prims.unit",
"Prims._assert",
"Hacl.Spec.K256.Field52.Definitions.as_nat5",
"Prims.op_Equality",
"Prims.nat",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.lemma_div_pow48",
"Prims.int",
"FStar.Mul.op_Star",
"Prims.op_Division",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Spec.K256.Field52.Definitions.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Hacl.Spec.K256.Field52.Lemmas2.minus_x_mul_pow2_256_lemma",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Hacl.Spec.K256.Field52.minus_x_mul_pow2_256",
"FStar.Math.Lemmas.pow2_double_sum",
"Hacl.Spec.K256.Field52.Lemmas2.plus_x_mul_pow2_256_minus_prime_lemma",
"Hacl.Spec.K256.Field52.plus_x_mul_pow2_256_minus_prime",
"FStar.UInt.logor_lemma_1",
"FStar.UInt.logor_commutative",
"Lib.IntTypes.logor_spec",
"Lib.IntTypes.op_Bar_Dot",
"Lib.IntTypes.logand_lemma",
"Lib.IntTypes.u64",
"Lib.IntTypes.op_Amp_Dot",
"Hacl.Spec.K256.Field52.Lemmas2.is_felem_ge_prime5_lemma",
"Hacl.Spec.K256.Field52.is_felem_ge_prime5",
"Prims.op_LessThanOrEqual",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.lemma_as_nat_bound_f4_lt_pow12"
] | [] | module Hacl.Spec.K256.Field52.Lemmas2
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
include Hacl.Spec.K256.Field52
module ML = Hacl.Spec.K256.MathLemmas
module LD = Hacl.Spec.K256.Field52.Definitions.Lemmas
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
/// Normalize-weak
val minus_x_mul_pow2_256_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires felem_fits5 f m)
(ensures
(let x, r = minus_x_mul_pow2_256 f in
let (r0,r1,r2,r3,r4) = r in
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
v x < pow2 16 /\ v x = v t4 / pow2 48 /\
v r4 = v t4 % pow2 48 /\
as_nat5 r == as_nat5 f - v x * pow2 256 /\
felem_fits5 r (m0,m1,m2,m3,1)))
let minus_x_mul_pow2_256_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
let x = t4 >>. 48ul in let t4' = t4 &. mask48 in
LD.lemma_mask48 t4;
let r = (t0,t1,t2,t3,t4') in
calc (==) { // as_nat5 f
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + v t4 * pow208;
(==) { Math.Lemmas.euclidean_division_definition (v t4) (pow2 48) }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48 + v t4 % pow2 48) * pow208;
(==) { Math.Lemmas.distributivity_add_left (v t4 / pow2 48 * pow2 48) (v t4 % pow2 48) pow208 }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48) * pow208 + (v t4 % pow2 48) * pow208;
(==) { }
(v x * pow2 48) * pow208 + as_nat5 r;
(==) { Math.Lemmas.paren_mul_right (v x) (pow2 48) pow208; Math.Lemmas.pow2_plus 48 208 }
v x * pow2 256 + as_nat5 r;
};
Math.Lemmas.lemma_div_lt (v t4) 64 48
val carry_round_after_last_carry_mod_prime5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f (m0,m1,m2,m3,1)))
(ensures (let r = carry_round5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let carry_round_after_last_carry_mod_prime5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in //(m0,m1,m2,m3,1)
let t1' = t1 +. (t0 >>. 52ul) in let t0' = t0 &. mask52 in
LD.lemma_carry52 m1 m0 t1 t0;
assert (felem_fits1 t1' (m1 + 1));
assert (felem_fits1 t0' 1);
assert (v t0' = v t0 % pow2 52);
assert (v t1' = v t1 + v t0 / pow2 52);
let t2' = t2 +. (t1' >>. 52ul) in let t1'' = t1' &. mask52 in
LD.lemma_carry52 m2 (m1 + 1) t2 t1';
assert (felem_fits1 t2' (m2 + 1));
assert (felem_fits1 t1'' 1);
assert (v t1'' = v t1' % pow2 52);
assert (v t2' = v t2 + v t1' / pow2 52);
let t3' = t3 +. (t2' >>. 52ul) in let t2'' = t2' &. mask52 in
LD.lemma_carry52 m3 (m2 + 1) t3 t2';
assert (felem_fits1 t3' (m3 + 1));
assert (felem_fits1 t2'' 1);
assert (v t2'' = v t2' % pow2 52);
assert (v t3' = v t3 + v t2' / pow2 52);
let t4' = t4 +. (t3' >>. 52ul) in let t3'' = t3' &. mask52 in
LD.lemma_carry_last52 m4 (m3 + 1) t4 t3';
assert (felem_fits_last1 t4' (m4 + 1));
assert (felem_fits1 t3'' 1);
assert (v t3'' = v t3' % pow2 52);
assert (v t4' = v t4 + v t3' / pow2 52);
LD.carry_last_small_mod_lemma t4 t3';
ML.lemma_simplify_carry_round (v t0) (v t1) (v t2) (v t3) (v t4);
let r = carry_round5 f in
assert ((t0',t1'',t2'',t3'',t4') == r);
assert (as_nat5 r == as_nat5 f)
val plus_x_mul_pow2_256_minus_prime_lemma: m:scale64_5 -> x:uint64 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f m /\ v x < pow2 16))
(ensures
(let r = plus_x_mul_pow2_256_minus_prime x f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime) /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let plus_x_mul_pow2_256_minus_prime_lemma m x f =
let (t0,t1,t2,t3,t4) = f in
let (m0,m1,m2,m3,m4) = m in
let t0' = t0 +. x *. u64 0x1000003D1 in
assert (v x < pow2 16);
Math.Lemmas.lemma_mult_lt_right 0x1000003D1 (v x) (pow2 16);
assert_norm (pow2 16 * 0x1000003D1 < max52);
assert (v t0 + v x * 0x1000003D1 < (m0 + 1) * max52);
Math.Lemmas.lemma_mult_le_right max52 (m0 + 1) 4096;
assert_norm (4096 * max52 < pow2 64);
Math.Lemmas.small_mod (v t0 + v x * 0x1000003D1) (pow2 64);
assert (v t0' = v t0 + v x * 0x1000003D1);
assert (felem_fits1 t0' (m0 + 1));
let r = carry_round5 (t0',t1,t2,t3,t4) in
carry_round_after_last_carry_mod_prime5_lemma (m0+1,m1,m2,m3,m4) (t0',t1,t2,t3,t4);
assert (as_nat5 r == as_nat5 (t0',t1,t2,t3,t4));
LD.lemma_pow2_256_minus_prime ();
assert (as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime))
val normalize_weak5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let r = normalize_weak5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f - v t4 / pow2 48 * S.prime /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let normalize_weak5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let x, f1 = minus_x_mul_pow2_256 f in
minus_x_mul_pow2_256_lemma m f;
assert (as_nat5 f1 == as_nat5 f - v x * pow2 256);
assert (felem_fits5 f1 (m0,m1,m2,m3,1));
let f2 = plus_x_mul_pow2_256_minus_prime x f1 in
plus_x_mul_pow2_256_minus_prime_lemma (m0,m1,m2,m3,1) x f1;
assert (as_nat5 f2 == as_nat5 f1 + v x * (pow2 256 - S.prime));
assert (felem_fits5 f2 (1,1,1,1,2));
assert (f2 == normalize_weak5 f);
Math.Lemmas.distributivity_sub_right (v x) (pow2 256) S.prime;
assert (as_nat5 f2 == as_nat5 f - v x * S.prime)
/// Normalize
#push-options "--ifuel 1"
val is_felem_ge_prime5_lemma: f:felem5 -> Lemma
(requires felem_fits5 f (1,1,1,1,1))
(ensures (let is_m = is_felem_ge_prime5 f in
(v is_m = 0 \/ v is_m = ones_v U64) /\
(if v is_m = ones_v U64 then (as_nat5 f >= S.prime) else (as_nat5 f < S.prime))))
let is_felem_ge_prime5_lemma f = ()
#pop-options
// let (f0,f1,f2,f3,f4) = f in
// let m4 = eq_mask f4 mask48 in
// eq_mask_lemma f4 mask48;
// assert (if v f4 = v mask48 then v m4 = ones_v U64 else v m4 = 0);
// let m3 = eq_mask f3 mask52 in
// eq_mask_lemma f3 mask52;
// assert (if v f3 = v mask52 then v m3 = ones_v U64 else v m3 = 0);
// let m2 = eq_mask f2 mask52 in
// eq_mask_lemma f2 mask52;
// assert (if v f2 = v mask52 then v m2 = ones_v U64 else v m2 = 0);
// let m1 = eq_mask f1 mask52 in
// eq_mask_lemma f1 mask52;
// assert (if v f1 = v mask52 then v m1 = ones_v U64 else v m1 = 0);
// let m0 = gte_mask f0 (u64 0xffffefffffc2f) in
// gte_mask_lemma f0 (u64 0xffffefffffc2f);
// assert (if v f0 >= 0xffffefffffc2f then v m0 = ones_v U64 else v m0 = 0);
// let m = m0 &. m1 &. m2 &. m3 &. m4 in ()
// if v m4 = 0 then
// logand_zeros (m0 &. m1 &. m2 &. m3)
// else begin
// logand_ones (m0 &. m1 &. m2 &. m3) end
noextract
let normalize5_first_part (f0,f1,f2,f3,f4) =
let (t0,t1,t2,t3,t4) = normalize_weak5 (f0,f1,f2,f3,f4) in
let x, (r0,r1,r2,r3,r4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
x, (r0,r1,r2,r3,r4)
noextract
let normalize5_second_part_x (x:uint64) (r0,r1,r2,r3,r4) : felem5 =
let is_ge_p_m = is_felem_ge_prime5 (r0,r1,r2,r3,r4) in // as_nat r >= S.prime
let m_to_one = is_ge_p_m &. u64 1 in
let x1 = m_to_one |. x in
let (s0,s1,s2,s3,s4) = plus_x_mul_pow2_256_minus_prime x1 (r0,r1,r2,r3,r4) in
let x2, (k0,k1,k2,k3,k4) = minus_x_mul_pow2_256 (s0,s1,s2,s3,s4) in
(k0,k1,k2,k3,k4)
val normalize5_first_part_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let x, r = normalize5_first_part f in
let (f0,f1,f2,f3,f4) = f in
let (r0,r1,r2,r3,r4) = r in
as_nat5 r == as_nat5 f - v f4 / pow2 48 * S.prime - v x * pow2 256 /\
felem_fits5 r (1,1,1,1,1) /\ (v x = 0 \/ (v x = 1 /\ v r4 < pow2 12))))
let normalize5_first_part_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (f0,f1,f2,f3,f4) = f in
let t = normalize_weak5 f in
let (t0,t1,t2,t3,t4) = t in
normalize_weak5_lemma m f;
assert (as_nat5 t == as_nat5 f - v f4 / pow2 48 * S.prime);
assert (felem_fits5 t (1,1,1,1,2));
assert ((v t4 >= pow2 48 ==> v t4 % pow2 48 < pow2 12));
let x, r = minus_x_mul_pow2_256 t in
let (r0,r1,r2,r3,r4) = r in
minus_x_mul_pow2_256_lemma (1,1,1,1,2) t;
assert (as_nat5 r == as_nat5 t - v x * pow2 256);
assert (as_nat5 r == as_nat5 f - v f4 / pow2 48 * S.prime - v x * pow2 256);
assert (felem_fits5 r (1,1,1,1,1));
assert (v r4 = v t4 % pow2 48 /\ v x = v t4 / pow2 48);
LD.lemma_div_pow48 t4;
assert (if v t4 < pow2 48 then v x = 0 else v x = 1 /\ v r4 < pow2 12)
val normalize5_second_part_x_is_one_lemma: x:uint64 -> r:felem5 -> Lemma
(requires (let (r0,r1,r2,r3,r4) = r in
felem_fits5 r (1,1,1,1,1) /\ v x = 1 /\ v r4 < pow2 12))
(ensures (let k = normalize5_second_part_x x r in
as_nat5 k == as_nat5 r + v x * pow2 256 - S.prime /\
felem_fits5 k (1,1,1,1,1) /\ as_nat5 k < S.prime)) | false | false | Hacl.Spec.K256.Field52.Lemmas2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val normalize5_second_part_x_is_one_lemma: x:uint64 -> r:felem5 -> Lemma
(requires (let (r0,r1,r2,r3,r4) = r in
felem_fits5 r (1,1,1,1,1) /\ v x = 1 /\ v r4 < pow2 12))
(ensures (let k = normalize5_second_part_x x r in
as_nat5 k == as_nat5 r + v x * pow2 256 - S.prime /\
felem_fits5 k (1,1,1,1,1) /\ as_nat5 k < S.prime)) | [] | Hacl.Spec.K256.Field52.Lemmas2.normalize5_second_part_x_is_one_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.Lemmas2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Lib.IntTypes.uint64 -> r: Hacl.Spec.K256.Field52.Definitions.felem5
-> FStar.Pervasives.Lemma
(requires
(let _ = r in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ r4 = _ in
Hacl.Spec.K256.Field52.Definitions.felem_fits5 r (1, 1, 1, 1, 1) /\ Lib.IntTypes.v x = 1 /\
Lib.IntTypes.v r4 < Prims.pow2 12)
<:
Type0))
(ensures
(let k = Hacl.Spec.K256.Field52.Lemmas2.normalize5_second_part_x x r in
Hacl.Spec.K256.Field52.Definitions.as_nat5 k ==
Hacl.Spec.K256.Field52.Definitions.as_nat5 r + Lib.IntTypes.v x * Prims.pow2 256 -
Spec.K256.PointOps.prime /\
Hacl.Spec.K256.Field52.Definitions.felem_fits5 k (1, 1, 1, 1, 1) /\
Hacl.Spec.K256.Field52.Definitions.as_nat5 k < Spec.K256.PointOps.prime)) | {
"end_col": 55,
"end_line": 294,
"start_col": 2,
"start_line": 260
} |
FStar.Pervasives.Lemma | val normalize5_first_part_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let x, r = normalize5_first_part f in
let (f0,f1,f2,f3,f4) = f in
let (r0,r1,r2,r3,r4) = r in
as_nat5 r == as_nat5 f - v f4 / pow2 48 * S.prime - v x * pow2 256 /\
felem_fits5 r (1,1,1,1,1) /\ (v x = 0 \/ (v x = 1 /\ v r4 < pow2 12)))) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Definitions.Lemmas",
"short_module": "LD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.MathLemmas",
"short_module": "ML"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let normalize5_first_part_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (f0,f1,f2,f3,f4) = f in
let t = normalize_weak5 f in
let (t0,t1,t2,t3,t4) = t in
normalize_weak5_lemma m f;
assert (as_nat5 t == as_nat5 f - v f4 / pow2 48 * S.prime);
assert (felem_fits5 t (1,1,1,1,2));
assert ((v t4 >= pow2 48 ==> v t4 % pow2 48 < pow2 12));
let x, r = minus_x_mul_pow2_256 t in
let (r0,r1,r2,r3,r4) = r in
minus_x_mul_pow2_256_lemma (1,1,1,1,2) t;
assert (as_nat5 r == as_nat5 t - v x * pow2 256);
assert (as_nat5 r == as_nat5 f - v f4 / pow2 48 * S.prime - v x * pow2 256);
assert (felem_fits5 r (1,1,1,1,1));
assert (v r4 = v t4 % pow2 48 /\ v x = v t4 / pow2 48);
LD.lemma_div_pow48 t4;
assert (if v t4 < pow2 48 then v x = 0 else v x = 1 /\ v r4 < pow2 12) | val normalize5_first_part_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let x, r = normalize5_first_part f in
let (f0,f1,f2,f3,f4) = f in
let (r0,r1,r2,r3,r4) = r in
as_nat5 r == as_nat5 f - v f4 / pow2 48 * S.prime - v x * pow2 256 /\
felem_fits5 r (1,1,1,1,1) /\ (v x = 0 \/ (v x = 1 /\ v r4 < pow2 12))))
let normalize5_first_part_lemma m f = | false | null | true | let m0, m1, m2, m3, m4 = m in
let f0, f1, f2, f3, f4 = f in
let t = normalize_weak5 f in
let t0, t1, t2, t3, t4 = t in
normalize_weak5_lemma m f;
assert (as_nat5 t == as_nat5 f - (v f4 / pow2 48) * S.prime);
assert (felem_fits5 t (1, 1, 1, 1, 2));
assert ((v t4 >= pow2 48 ==> v t4 % pow2 48 < pow2 12));
let x, r = minus_x_mul_pow2_256 t in
let r0, r1, r2, r3, r4 = r in
minus_x_mul_pow2_256_lemma (1, 1, 1, 1, 2) t;
assert (as_nat5 r == as_nat5 t - v x * pow2 256);
assert (as_nat5 r == as_nat5 f - (v f4 / pow2 48) * S.prime - v x * pow2 256);
assert (felem_fits5 r (1, 1, 1, 1, 1));
assert (v r4 = v t4 % pow2 48 /\ v x = v t4 / pow2 48);
LD.lemma_div_pow48 t4;
assert (if v t4 < pow2 48 then v x = 0 else v x = 1 /\ v r4 < pow2 12) | {
"checked_file": "Hacl.Spec.K256.Field52.Lemmas2.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.MathLemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.Lemmas2.fst"
} | [
"lemma"
] | [
"Hacl.Spec.K256.Field52.Definitions.scale64_5",
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Prims.nat",
"Lib.IntTypes.uint64",
"Prims._assert",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.pow2",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Prims.l_and",
"Prims.unit",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.lemma_div_pow48",
"Prims.op_Modulus",
"Prims.op_Division",
"Hacl.Spec.K256.Field52.Definitions.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.eq2",
"Hacl.Spec.K256.Field52.Definitions.as_nat5",
"Prims.op_Subtraction",
"FStar.Mul.op_Star",
"Spec.K256.PointOps.prime",
"Hacl.Spec.K256.Field52.Lemmas2.minus_x_mul_pow2_256_lemma",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Hacl.Spec.K256.Field52.minus_x_mul_pow2_256",
"Prims.l_imp",
"Prims.op_GreaterThanOrEqual",
"Hacl.Spec.K256.Field52.Lemmas2.normalize_weak5_lemma",
"Hacl.Spec.K256.Field52.normalize_weak5"
] | [] | module Hacl.Spec.K256.Field52.Lemmas2
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
include Hacl.Spec.K256.Field52
module ML = Hacl.Spec.K256.MathLemmas
module LD = Hacl.Spec.K256.Field52.Definitions.Lemmas
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
/// Normalize-weak
val minus_x_mul_pow2_256_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires felem_fits5 f m)
(ensures
(let x, r = minus_x_mul_pow2_256 f in
let (r0,r1,r2,r3,r4) = r in
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
v x < pow2 16 /\ v x = v t4 / pow2 48 /\
v r4 = v t4 % pow2 48 /\
as_nat5 r == as_nat5 f - v x * pow2 256 /\
felem_fits5 r (m0,m1,m2,m3,1)))
let minus_x_mul_pow2_256_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
let x = t4 >>. 48ul in let t4' = t4 &. mask48 in
LD.lemma_mask48 t4;
let r = (t0,t1,t2,t3,t4') in
calc (==) { // as_nat5 f
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + v t4 * pow208;
(==) { Math.Lemmas.euclidean_division_definition (v t4) (pow2 48) }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48 + v t4 % pow2 48) * pow208;
(==) { Math.Lemmas.distributivity_add_left (v t4 / pow2 48 * pow2 48) (v t4 % pow2 48) pow208 }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48) * pow208 + (v t4 % pow2 48) * pow208;
(==) { }
(v x * pow2 48) * pow208 + as_nat5 r;
(==) { Math.Lemmas.paren_mul_right (v x) (pow2 48) pow208; Math.Lemmas.pow2_plus 48 208 }
v x * pow2 256 + as_nat5 r;
};
Math.Lemmas.lemma_div_lt (v t4) 64 48
val carry_round_after_last_carry_mod_prime5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f (m0,m1,m2,m3,1)))
(ensures (let r = carry_round5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let carry_round_after_last_carry_mod_prime5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in //(m0,m1,m2,m3,1)
let t1' = t1 +. (t0 >>. 52ul) in let t0' = t0 &. mask52 in
LD.lemma_carry52 m1 m0 t1 t0;
assert (felem_fits1 t1' (m1 + 1));
assert (felem_fits1 t0' 1);
assert (v t0' = v t0 % pow2 52);
assert (v t1' = v t1 + v t0 / pow2 52);
let t2' = t2 +. (t1' >>. 52ul) in let t1'' = t1' &. mask52 in
LD.lemma_carry52 m2 (m1 + 1) t2 t1';
assert (felem_fits1 t2' (m2 + 1));
assert (felem_fits1 t1'' 1);
assert (v t1'' = v t1' % pow2 52);
assert (v t2' = v t2 + v t1' / pow2 52);
let t3' = t3 +. (t2' >>. 52ul) in let t2'' = t2' &. mask52 in
LD.lemma_carry52 m3 (m2 + 1) t3 t2';
assert (felem_fits1 t3' (m3 + 1));
assert (felem_fits1 t2'' 1);
assert (v t2'' = v t2' % pow2 52);
assert (v t3' = v t3 + v t2' / pow2 52);
let t4' = t4 +. (t3' >>. 52ul) in let t3'' = t3' &. mask52 in
LD.lemma_carry_last52 m4 (m3 + 1) t4 t3';
assert (felem_fits_last1 t4' (m4 + 1));
assert (felem_fits1 t3'' 1);
assert (v t3'' = v t3' % pow2 52);
assert (v t4' = v t4 + v t3' / pow2 52);
LD.carry_last_small_mod_lemma t4 t3';
ML.lemma_simplify_carry_round (v t0) (v t1) (v t2) (v t3) (v t4);
let r = carry_round5 f in
assert ((t0',t1'',t2'',t3'',t4') == r);
assert (as_nat5 r == as_nat5 f)
val plus_x_mul_pow2_256_minus_prime_lemma: m:scale64_5 -> x:uint64 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f m /\ v x < pow2 16))
(ensures
(let r = plus_x_mul_pow2_256_minus_prime x f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime) /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let plus_x_mul_pow2_256_minus_prime_lemma m x f =
let (t0,t1,t2,t3,t4) = f in
let (m0,m1,m2,m3,m4) = m in
let t0' = t0 +. x *. u64 0x1000003D1 in
assert (v x < pow2 16);
Math.Lemmas.lemma_mult_lt_right 0x1000003D1 (v x) (pow2 16);
assert_norm (pow2 16 * 0x1000003D1 < max52);
assert (v t0 + v x * 0x1000003D1 < (m0 + 1) * max52);
Math.Lemmas.lemma_mult_le_right max52 (m0 + 1) 4096;
assert_norm (4096 * max52 < pow2 64);
Math.Lemmas.small_mod (v t0 + v x * 0x1000003D1) (pow2 64);
assert (v t0' = v t0 + v x * 0x1000003D1);
assert (felem_fits1 t0' (m0 + 1));
let r = carry_round5 (t0',t1,t2,t3,t4) in
carry_round_after_last_carry_mod_prime5_lemma (m0+1,m1,m2,m3,m4) (t0',t1,t2,t3,t4);
assert (as_nat5 r == as_nat5 (t0',t1,t2,t3,t4));
LD.lemma_pow2_256_minus_prime ();
assert (as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime))
val normalize_weak5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let r = normalize_weak5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f - v t4 / pow2 48 * S.prime /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let normalize_weak5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let x, f1 = minus_x_mul_pow2_256 f in
minus_x_mul_pow2_256_lemma m f;
assert (as_nat5 f1 == as_nat5 f - v x * pow2 256);
assert (felem_fits5 f1 (m0,m1,m2,m3,1));
let f2 = plus_x_mul_pow2_256_minus_prime x f1 in
plus_x_mul_pow2_256_minus_prime_lemma (m0,m1,m2,m3,1) x f1;
assert (as_nat5 f2 == as_nat5 f1 + v x * (pow2 256 - S.prime));
assert (felem_fits5 f2 (1,1,1,1,2));
assert (f2 == normalize_weak5 f);
Math.Lemmas.distributivity_sub_right (v x) (pow2 256) S.prime;
assert (as_nat5 f2 == as_nat5 f - v x * S.prime)
/// Normalize
#push-options "--ifuel 1"
val is_felem_ge_prime5_lemma: f:felem5 -> Lemma
(requires felem_fits5 f (1,1,1,1,1))
(ensures (let is_m = is_felem_ge_prime5 f in
(v is_m = 0 \/ v is_m = ones_v U64) /\
(if v is_m = ones_v U64 then (as_nat5 f >= S.prime) else (as_nat5 f < S.prime))))
let is_felem_ge_prime5_lemma f = ()
#pop-options
// let (f0,f1,f2,f3,f4) = f in
// let m4 = eq_mask f4 mask48 in
// eq_mask_lemma f4 mask48;
// assert (if v f4 = v mask48 then v m4 = ones_v U64 else v m4 = 0);
// let m3 = eq_mask f3 mask52 in
// eq_mask_lemma f3 mask52;
// assert (if v f3 = v mask52 then v m3 = ones_v U64 else v m3 = 0);
// let m2 = eq_mask f2 mask52 in
// eq_mask_lemma f2 mask52;
// assert (if v f2 = v mask52 then v m2 = ones_v U64 else v m2 = 0);
// let m1 = eq_mask f1 mask52 in
// eq_mask_lemma f1 mask52;
// assert (if v f1 = v mask52 then v m1 = ones_v U64 else v m1 = 0);
// let m0 = gte_mask f0 (u64 0xffffefffffc2f) in
// gte_mask_lemma f0 (u64 0xffffefffffc2f);
// assert (if v f0 >= 0xffffefffffc2f then v m0 = ones_v U64 else v m0 = 0);
// let m = m0 &. m1 &. m2 &. m3 &. m4 in ()
// if v m4 = 0 then
// logand_zeros (m0 &. m1 &. m2 &. m3)
// else begin
// logand_ones (m0 &. m1 &. m2 &. m3) end
noextract
let normalize5_first_part (f0,f1,f2,f3,f4) =
let (t0,t1,t2,t3,t4) = normalize_weak5 (f0,f1,f2,f3,f4) in
let x, (r0,r1,r2,r3,r4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
x, (r0,r1,r2,r3,r4)
noextract
let normalize5_second_part_x (x:uint64) (r0,r1,r2,r3,r4) : felem5 =
let is_ge_p_m = is_felem_ge_prime5 (r0,r1,r2,r3,r4) in // as_nat r >= S.prime
let m_to_one = is_ge_p_m &. u64 1 in
let x1 = m_to_one |. x in
let (s0,s1,s2,s3,s4) = plus_x_mul_pow2_256_minus_prime x1 (r0,r1,r2,r3,r4) in
let x2, (k0,k1,k2,k3,k4) = minus_x_mul_pow2_256 (s0,s1,s2,s3,s4) in
(k0,k1,k2,k3,k4)
val normalize5_first_part_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let x, r = normalize5_first_part f in
let (f0,f1,f2,f3,f4) = f in
let (r0,r1,r2,r3,r4) = r in
as_nat5 r == as_nat5 f - v f4 / pow2 48 * S.prime - v x * pow2 256 /\
felem_fits5 r (1,1,1,1,1) /\ (v x = 0 \/ (v x = 1 /\ v r4 < pow2 12)))) | false | false | Hacl.Spec.K256.Field52.Lemmas2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val normalize5_first_part_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let x, r = normalize5_first_part f in
let (f0,f1,f2,f3,f4) = f in
let (r0,r1,r2,r3,r4) = r in
as_nat5 r == as_nat5 f - v f4 / pow2 48 * S.prime - v x * pow2 256 /\
felem_fits5 r (1,1,1,1,1) /\ (v x = 0 \/ (v x = 1 /\ v r4 < pow2 12)))) | [] | Hacl.Spec.K256.Field52.Lemmas2.normalize5_first_part_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.Lemmas2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | m: Hacl.Spec.K256.Field52.Definitions.scale64_5 -> f: Hacl.Spec.K256.Field52.Definitions.felem5
-> FStar.Pervasives.Lemma
(requires
(let _ = m in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ m0 m1 m2 m3 _ = _ in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
Hacl.Spec.K256.Field52.Definitions.felem_fits5 f m)
<:
Type0))
(ensures
(let _ = Hacl.Spec.K256.Field52.Lemmas2.normalize5_first_part f in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ x r = _ in
let _ = f in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ f4 = _ in
let _ = r in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ r4 = _ in
Hacl.Spec.K256.Field52.Definitions.as_nat5 r ==
Hacl.Spec.K256.Field52.Definitions.as_nat5 f -
(Lib.IntTypes.v f4 / Prims.pow2 48) * Spec.K256.PointOps.prime -
Lib.IntTypes.v x * Prims.pow2 256 /\
Hacl.Spec.K256.Field52.Definitions.felem_fits5 r (1, 1, 1, 1, 1) /\
(Lib.IntTypes.v x = 0 \/ Lib.IntTypes.v x = 1 /\ Lib.IntTypes.v r4 < Prims.pow2 12))
<:
Type0)
<:
Type0)
<:
Type0)) | {
"end_col": 72,
"end_line": 249,
"start_col": 37,
"start_line": 231
} |
FStar.Pervasives.Lemma | val plus_x_mul_pow2_256_minus_prime_lemma: m:scale64_5 -> x:uint64 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f m /\ v x < pow2 16))
(ensures
(let r = plus_x_mul_pow2_256_minus_prime x f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime) /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12))) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Definitions.Lemmas",
"short_module": "LD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.MathLemmas",
"short_module": "ML"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let plus_x_mul_pow2_256_minus_prime_lemma m x f =
let (t0,t1,t2,t3,t4) = f in
let (m0,m1,m2,m3,m4) = m in
let t0' = t0 +. x *. u64 0x1000003D1 in
assert (v x < pow2 16);
Math.Lemmas.lemma_mult_lt_right 0x1000003D1 (v x) (pow2 16);
assert_norm (pow2 16 * 0x1000003D1 < max52);
assert (v t0 + v x * 0x1000003D1 < (m0 + 1) * max52);
Math.Lemmas.lemma_mult_le_right max52 (m0 + 1) 4096;
assert_norm (4096 * max52 < pow2 64);
Math.Lemmas.small_mod (v t0 + v x * 0x1000003D1) (pow2 64);
assert (v t0' = v t0 + v x * 0x1000003D1);
assert (felem_fits1 t0' (m0 + 1));
let r = carry_round5 (t0',t1,t2,t3,t4) in
carry_round_after_last_carry_mod_prime5_lemma (m0+1,m1,m2,m3,m4) (t0',t1,t2,t3,t4);
assert (as_nat5 r == as_nat5 (t0',t1,t2,t3,t4));
LD.lemma_pow2_256_minus_prime ();
assert (as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime)) | val plus_x_mul_pow2_256_minus_prime_lemma: m:scale64_5 -> x:uint64 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f m /\ v x < pow2 16))
(ensures
(let r = plus_x_mul_pow2_256_minus_prime x f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime) /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let plus_x_mul_pow2_256_minus_prime_lemma m x f = | false | null | true | let t0, t1, t2, t3, t4 = f in
let m0, m1, m2, m3, m4 = m in
let t0' = t0 +. x *. u64 0x1000003D1 in
assert (v x < pow2 16);
Math.Lemmas.lemma_mult_lt_right 0x1000003D1 (v x) (pow2 16);
assert_norm (pow2 16 * 0x1000003D1 < max52);
assert (v t0 + v x * 0x1000003D1 < (m0 + 1) * max52);
Math.Lemmas.lemma_mult_le_right max52 (m0 + 1) 4096;
assert_norm (4096 * max52 < pow2 64);
Math.Lemmas.small_mod (v t0 + v x * 0x1000003D1) (pow2 64);
assert (v t0' = v t0 + v x * 0x1000003D1);
assert (felem_fits1 t0' (m0 + 1));
let r = carry_round5 (t0', t1, t2, t3, t4) in
carry_round_after_last_carry_mod_prime5_lemma (m0 + 1, m1, m2, m3, m4) (t0', t1, t2, t3, t4);
assert (as_nat5 r == as_nat5 (t0', t1, t2, t3, t4));
LD.lemma_pow2_256_minus_prime ();
assert (as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime)) | {
"checked_file": "Hacl.Spec.K256.Field52.Lemmas2.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.MathLemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.Lemmas2.fst"
} | [
"lemma"
] | [
"Hacl.Spec.K256.Field52.Definitions.scale64_5",
"Lib.IntTypes.uint64",
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Prims.nat",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Hacl.Spec.K256.Field52.Definitions.as_nat5",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.op_Subtraction",
"Prims.pow2",
"Spec.K256.PointOps.prime",
"Prims.unit",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.lemma_pow2_256_minus_prime",
"FStar.Pervasives.Native.Mktuple5",
"Hacl.Spec.K256.Field52.Lemmas2.carry_round_after_last_carry_mod_prime5_lemma",
"Hacl.Spec.K256.Field52.carry_round5",
"Prims.b2t",
"Hacl.Spec.K256.Field52.Definitions.felem_fits1",
"Prims.op_Equality",
"FStar.Math.Lemmas.small_mod",
"FStar.Pervasives.assert_norm",
"Prims.op_LessThan",
"Hacl.Spec.K256.Field52.Definitions.max52",
"FStar.Math.Lemmas.lemma_mult_le_right",
"FStar.Math.Lemmas.lemma_mult_lt_right",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.u64"
] | [] | module Hacl.Spec.K256.Field52.Lemmas2
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
include Hacl.Spec.K256.Field52
module ML = Hacl.Spec.K256.MathLemmas
module LD = Hacl.Spec.K256.Field52.Definitions.Lemmas
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
/// Normalize-weak
val minus_x_mul_pow2_256_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires felem_fits5 f m)
(ensures
(let x, r = minus_x_mul_pow2_256 f in
let (r0,r1,r2,r3,r4) = r in
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
v x < pow2 16 /\ v x = v t4 / pow2 48 /\
v r4 = v t4 % pow2 48 /\
as_nat5 r == as_nat5 f - v x * pow2 256 /\
felem_fits5 r (m0,m1,m2,m3,1)))
let minus_x_mul_pow2_256_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
let x = t4 >>. 48ul in let t4' = t4 &. mask48 in
LD.lemma_mask48 t4;
let r = (t0,t1,t2,t3,t4') in
calc (==) { // as_nat5 f
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + v t4 * pow208;
(==) { Math.Lemmas.euclidean_division_definition (v t4) (pow2 48) }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48 + v t4 % pow2 48) * pow208;
(==) { Math.Lemmas.distributivity_add_left (v t4 / pow2 48 * pow2 48) (v t4 % pow2 48) pow208 }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48) * pow208 + (v t4 % pow2 48) * pow208;
(==) { }
(v x * pow2 48) * pow208 + as_nat5 r;
(==) { Math.Lemmas.paren_mul_right (v x) (pow2 48) pow208; Math.Lemmas.pow2_plus 48 208 }
v x * pow2 256 + as_nat5 r;
};
Math.Lemmas.lemma_div_lt (v t4) 64 48
val carry_round_after_last_carry_mod_prime5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f (m0,m1,m2,m3,1)))
(ensures (let r = carry_round5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let carry_round_after_last_carry_mod_prime5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in //(m0,m1,m2,m3,1)
let t1' = t1 +. (t0 >>. 52ul) in let t0' = t0 &. mask52 in
LD.lemma_carry52 m1 m0 t1 t0;
assert (felem_fits1 t1' (m1 + 1));
assert (felem_fits1 t0' 1);
assert (v t0' = v t0 % pow2 52);
assert (v t1' = v t1 + v t0 / pow2 52);
let t2' = t2 +. (t1' >>. 52ul) in let t1'' = t1' &. mask52 in
LD.lemma_carry52 m2 (m1 + 1) t2 t1';
assert (felem_fits1 t2' (m2 + 1));
assert (felem_fits1 t1'' 1);
assert (v t1'' = v t1' % pow2 52);
assert (v t2' = v t2 + v t1' / pow2 52);
let t3' = t3 +. (t2' >>. 52ul) in let t2'' = t2' &. mask52 in
LD.lemma_carry52 m3 (m2 + 1) t3 t2';
assert (felem_fits1 t3' (m3 + 1));
assert (felem_fits1 t2'' 1);
assert (v t2'' = v t2' % pow2 52);
assert (v t3' = v t3 + v t2' / pow2 52);
let t4' = t4 +. (t3' >>. 52ul) in let t3'' = t3' &. mask52 in
LD.lemma_carry_last52 m4 (m3 + 1) t4 t3';
assert (felem_fits_last1 t4' (m4 + 1));
assert (felem_fits1 t3'' 1);
assert (v t3'' = v t3' % pow2 52);
assert (v t4' = v t4 + v t3' / pow2 52);
LD.carry_last_small_mod_lemma t4 t3';
ML.lemma_simplify_carry_round (v t0) (v t1) (v t2) (v t3) (v t4);
let r = carry_round5 f in
assert ((t0',t1'',t2'',t3'',t4') == r);
assert (as_nat5 r == as_nat5 f)
val plus_x_mul_pow2_256_minus_prime_lemma: m:scale64_5 -> x:uint64 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f m /\ v x < pow2 16))
(ensures
(let r = plus_x_mul_pow2_256_minus_prime x f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime) /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12))) | false | false | Hacl.Spec.K256.Field52.Lemmas2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val plus_x_mul_pow2_256_minus_prime_lemma: m:scale64_5 -> x:uint64 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f m /\ v x < pow2 16))
(ensures
(let r = plus_x_mul_pow2_256_minus_prime x f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime) /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12))) | [] | Hacl.Spec.K256.Field52.Lemmas2.plus_x_mul_pow2_256_minus_prime_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.Lemmas2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
m: Hacl.Spec.K256.Field52.Definitions.scale64_5 ->
x: Lib.IntTypes.uint64 ->
f: Hacl.Spec.K256.Field52.Definitions.felem5
-> FStar.Pervasives.Lemma
(requires
(let _ = m in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ m0 m1 m2 m3 m4 = _ in
let _ = f in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ _ = _ in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
Hacl.Spec.K256.Field52.Definitions.felem_fits5 f m /\ Lib.IntTypes.v x < Prims.pow2 16
)
<:
Type0)
<:
Type0))
(ensures
(let r = Hacl.Spec.K256.Field52.plus_x_mul_pow2_256_minus_prime x f in
let _ = r in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ r4 = _ in
let _ = f in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ t4 = _ in
Hacl.Spec.K256.Field52.Definitions.as_nat5 r ==
Hacl.Spec.K256.Field52.Definitions.as_nat5 f +
Lib.IntTypes.v x * (Prims.pow2 256 - Spec.K256.PointOps.prime) /\
Hacl.Spec.K256.Field52.Definitions.felem_fits5 r (1, 1, 1, 1, 2) /\
Lib.IntTypes.v r4 < Lib.IntTypes.v t4 + Prims.pow2 12 /\
(Lib.IntTypes.v r4 >= Prims.pow2 48 ==>
Lib.IntTypes.v r4 % Prims.pow2 48 < Prims.pow2 12))
<:
Type0)
<:
Type0)) | {
"end_col": 62,
"end_line": 134,
"start_col": 49,
"start_line": 115
} |
FStar.Pervasives.Lemma | val normalize5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let r = normalize5 f in
as_nat5 r == as_nat5 f % S.prime /\
felem_fits5 r (1,1,1,1,1))) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Definitions.Lemmas",
"short_module": "LD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.MathLemmas",
"short_module": "ML"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let normalize5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (f0,f1,f2,f3,f4) = f in
let x, r = normalize5_first_part f in
let k = normalize5_second_part_x x r in
let (r0,r1,r2,r3,r4) = r in
normalize5_first_part_lemma m f;
assert (as_nat5 r == as_nat5 f - v f4 / pow2 48 * S.prime - v x * pow2 256);
if v x = 1 then begin
normalize5_second_part_x_is_one_lemma x r;
lemma_a_minus_b_n_c_n_k (as_nat5 k) (as_nat5 f) (v f4 / pow2 48) 1 S.prime end
else begin
normalize5_second_part_x_is_zero_lemma x r;
if as_nat5 r < S.prime then
lemma_a_minus_b_n_c_n_k (as_nat5 k) (as_nat5 f) (v f4 / pow2 48) 0 S.prime
else
lemma_a_minus_b_n_c_n_k (as_nat5 k) (as_nat5 f) (v f4 / pow2 48) 1 S.prime end | val normalize5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let r = normalize5 f in
as_nat5 r == as_nat5 f % S.prime /\
felem_fits5 r (1,1,1,1,1)))
let normalize5_lemma m f = | false | null | true | let m0, m1, m2, m3, m4 = m in
let f0, f1, f2, f3, f4 = f in
let x, r = normalize5_first_part f in
let k = normalize5_second_part_x x r in
let r0, r1, r2, r3, r4 = r in
normalize5_first_part_lemma m f;
assert (as_nat5 r == as_nat5 f - (v f4 / pow2 48) * S.prime - v x * pow2 256);
if v x = 1
then
(normalize5_second_part_x_is_one_lemma x r;
lemma_a_minus_b_n_c_n_k (as_nat5 k) (as_nat5 f) (v f4 / pow2 48) 1 S.prime)
else
(normalize5_second_part_x_is_zero_lemma x r;
if as_nat5 r < S.prime
then lemma_a_minus_b_n_c_n_k (as_nat5 k) (as_nat5 f) (v f4 / pow2 48) 0 S.prime
else lemma_a_minus_b_n_c_n_k (as_nat5 k) (as_nat5 f) (v f4 / pow2 48) 1 S.prime) | {
"checked_file": "Hacl.Spec.K256.Field52.Lemmas2.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.MathLemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.Lemmas2.fst"
} | [
"lemma"
] | [
"Hacl.Spec.K256.Field52.Definitions.scale64_5",
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Prims.nat",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.tuple5",
"Prims.op_Equality",
"Prims.int",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Spec.K256.Field52.Lemmas2.lemma_a_minus_b_n_c_n_k",
"Hacl.Spec.K256.Field52.Definitions.as_nat5",
"Prims.op_Division",
"Prims.pow2",
"Spec.K256.PointOps.prime",
"Prims.unit",
"Hacl.Spec.K256.Field52.Lemmas2.normalize5_second_part_x_is_one_lemma",
"Prims.bool",
"Prims.op_LessThan",
"Hacl.Spec.K256.Field52.Lemmas2.normalize5_second_part_x_is_zero_lemma",
"Prims._assert",
"Prims.eq2",
"Prims.op_Subtraction",
"FStar.Mul.op_Star",
"Hacl.Spec.K256.Field52.Lemmas2.normalize5_first_part_lemma",
"Lib.IntTypes.int_t",
"Hacl.Spec.K256.Field52.Lemmas2.normalize5_second_part_x",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.K256.Field52.Lemmas2.normalize5_first_part"
] | [] | module Hacl.Spec.K256.Field52.Lemmas2
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
include Hacl.Spec.K256.Field52
module ML = Hacl.Spec.K256.MathLemmas
module LD = Hacl.Spec.K256.Field52.Definitions.Lemmas
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
/// Normalize-weak
val minus_x_mul_pow2_256_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires felem_fits5 f m)
(ensures
(let x, r = minus_x_mul_pow2_256 f in
let (r0,r1,r2,r3,r4) = r in
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
v x < pow2 16 /\ v x = v t4 / pow2 48 /\
v r4 = v t4 % pow2 48 /\
as_nat5 r == as_nat5 f - v x * pow2 256 /\
felem_fits5 r (m0,m1,m2,m3,1)))
let minus_x_mul_pow2_256_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
let x = t4 >>. 48ul in let t4' = t4 &. mask48 in
LD.lemma_mask48 t4;
let r = (t0,t1,t2,t3,t4') in
calc (==) { // as_nat5 f
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + v t4 * pow208;
(==) { Math.Lemmas.euclidean_division_definition (v t4) (pow2 48) }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48 + v t4 % pow2 48) * pow208;
(==) { Math.Lemmas.distributivity_add_left (v t4 / pow2 48 * pow2 48) (v t4 % pow2 48) pow208 }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48) * pow208 + (v t4 % pow2 48) * pow208;
(==) { }
(v x * pow2 48) * pow208 + as_nat5 r;
(==) { Math.Lemmas.paren_mul_right (v x) (pow2 48) pow208; Math.Lemmas.pow2_plus 48 208 }
v x * pow2 256 + as_nat5 r;
};
Math.Lemmas.lemma_div_lt (v t4) 64 48
val carry_round_after_last_carry_mod_prime5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f (m0,m1,m2,m3,1)))
(ensures (let r = carry_round5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let carry_round_after_last_carry_mod_prime5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in //(m0,m1,m2,m3,1)
let t1' = t1 +. (t0 >>. 52ul) in let t0' = t0 &. mask52 in
LD.lemma_carry52 m1 m0 t1 t0;
assert (felem_fits1 t1' (m1 + 1));
assert (felem_fits1 t0' 1);
assert (v t0' = v t0 % pow2 52);
assert (v t1' = v t1 + v t0 / pow2 52);
let t2' = t2 +. (t1' >>. 52ul) in let t1'' = t1' &. mask52 in
LD.lemma_carry52 m2 (m1 + 1) t2 t1';
assert (felem_fits1 t2' (m2 + 1));
assert (felem_fits1 t1'' 1);
assert (v t1'' = v t1' % pow2 52);
assert (v t2' = v t2 + v t1' / pow2 52);
let t3' = t3 +. (t2' >>. 52ul) in let t2'' = t2' &. mask52 in
LD.lemma_carry52 m3 (m2 + 1) t3 t2';
assert (felem_fits1 t3' (m3 + 1));
assert (felem_fits1 t2'' 1);
assert (v t2'' = v t2' % pow2 52);
assert (v t3' = v t3 + v t2' / pow2 52);
let t4' = t4 +. (t3' >>. 52ul) in let t3'' = t3' &. mask52 in
LD.lemma_carry_last52 m4 (m3 + 1) t4 t3';
assert (felem_fits_last1 t4' (m4 + 1));
assert (felem_fits1 t3'' 1);
assert (v t3'' = v t3' % pow2 52);
assert (v t4' = v t4 + v t3' / pow2 52);
LD.carry_last_small_mod_lemma t4 t3';
ML.lemma_simplify_carry_round (v t0) (v t1) (v t2) (v t3) (v t4);
let r = carry_round5 f in
assert ((t0',t1'',t2'',t3'',t4') == r);
assert (as_nat5 r == as_nat5 f)
val plus_x_mul_pow2_256_minus_prime_lemma: m:scale64_5 -> x:uint64 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f m /\ v x < pow2 16))
(ensures
(let r = plus_x_mul_pow2_256_minus_prime x f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime) /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let plus_x_mul_pow2_256_minus_prime_lemma m x f =
let (t0,t1,t2,t3,t4) = f in
let (m0,m1,m2,m3,m4) = m in
let t0' = t0 +. x *. u64 0x1000003D1 in
assert (v x < pow2 16);
Math.Lemmas.lemma_mult_lt_right 0x1000003D1 (v x) (pow2 16);
assert_norm (pow2 16 * 0x1000003D1 < max52);
assert (v t0 + v x * 0x1000003D1 < (m0 + 1) * max52);
Math.Lemmas.lemma_mult_le_right max52 (m0 + 1) 4096;
assert_norm (4096 * max52 < pow2 64);
Math.Lemmas.small_mod (v t0 + v x * 0x1000003D1) (pow2 64);
assert (v t0' = v t0 + v x * 0x1000003D1);
assert (felem_fits1 t0' (m0 + 1));
let r = carry_round5 (t0',t1,t2,t3,t4) in
carry_round_after_last_carry_mod_prime5_lemma (m0+1,m1,m2,m3,m4) (t0',t1,t2,t3,t4);
assert (as_nat5 r == as_nat5 (t0',t1,t2,t3,t4));
LD.lemma_pow2_256_minus_prime ();
assert (as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime))
val normalize_weak5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let r = normalize_weak5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f - v t4 / pow2 48 * S.prime /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let normalize_weak5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let x, f1 = minus_x_mul_pow2_256 f in
minus_x_mul_pow2_256_lemma m f;
assert (as_nat5 f1 == as_nat5 f - v x * pow2 256);
assert (felem_fits5 f1 (m0,m1,m2,m3,1));
let f2 = plus_x_mul_pow2_256_minus_prime x f1 in
plus_x_mul_pow2_256_minus_prime_lemma (m0,m1,m2,m3,1) x f1;
assert (as_nat5 f2 == as_nat5 f1 + v x * (pow2 256 - S.prime));
assert (felem_fits5 f2 (1,1,1,1,2));
assert (f2 == normalize_weak5 f);
Math.Lemmas.distributivity_sub_right (v x) (pow2 256) S.prime;
assert (as_nat5 f2 == as_nat5 f - v x * S.prime)
/// Normalize
#push-options "--ifuel 1"
val is_felem_ge_prime5_lemma: f:felem5 -> Lemma
(requires felem_fits5 f (1,1,1,1,1))
(ensures (let is_m = is_felem_ge_prime5 f in
(v is_m = 0 \/ v is_m = ones_v U64) /\
(if v is_m = ones_v U64 then (as_nat5 f >= S.prime) else (as_nat5 f < S.prime))))
let is_felem_ge_prime5_lemma f = ()
#pop-options
// let (f0,f1,f2,f3,f4) = f in
// let m4 = eq_mask f4 mask48 in
// eq_mask_lemma f4 mask48;
// assert (if v f4 = v mask48 then v m4 = ones_v U64 else v m4 = 0);
// let m3 = eq_mask f3 mask52 in
// eq_mask_lemma f3 mask52;
// assert (if v f3 = v mask52 then v m3 = ones_v U64 else v m3 = 0);
// let m2 = eq_mask f2 mask52 in
// eq_mask_lemma f2 mask52;
// assert (if v f2 = v mask52 then v m2 = ones_v U64 else v m2 = 0);
// let m1 = eq_mask f1 mask52 in
// eq_mask_lemma f1 mask52;
// assert (if v f1 = v mask52 then v m1 = ones_v U64 else v m1 = 0);
// let m0 = gte_mask f0 (u64 0xffffefffffc2f) in
// gte_mask_lemma f0 (u64 0xffffefffffc2f);
// assert (if v f0 >= 0xffffefffffc2f then v m0 = ones_v U64 else v m0 = 0);
// let m = m0 &. m1 &. m2 &. m3 &. m4 in ()
// if v m4 = 0 then
// logand_zeros (m0 &. m1 &. m2 &. m3)
// else begin
// logand_ones (m0 &. m1 &. m2 &. m3) end
noextract
let normalize5_first_part (f0,f1,f2,f3,f4) =
let (t0,t1,t2,t3,t4) = normalize_weak5 (f0,f1,f2,f3,f4) in
let x, (r0,r1,r2,r3,r4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
x, (r0,r1,r2,r3,r4)
noextract
let normalize5_second_part_x (x:uint64) (r0,r1,r2,r3,r4) : felem5 =
let is_ge_p_m = is_felem_ge_prime5 (r0,r1,r2,r3,r4) in // as_nat r >= S.prime
let m_to_one = is_ge_p_m &. u64 1 in
let x1 = m_to_one |. x in
let (s0,s1,s2,s3,s4) = plus_x_mul_pow2_256_minus_prime x1 (r0,r1,r2,r3,r4) in
let x2, (k0,k1,k2,k3,k4) = minus_x_mul_pow2_256 (s0,s1,s2,s3,s4) in
(k0,k1,k2,k3,k4)
val normalize5_first_part_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let x, r = normalize5_first_part f in
let (f0,f1,f2,f3,f4) = f in
let (r0,r1,r2,r3,r4) = r in
as_nat5 r == as_nat5 f - v f4 / pow2 48 * S.prime - v x * pow2 256 /\
felem_fits5 r (1,1,1,1,1) /\ (v x = 0 \/ (v x = 1 /\ v r4 < pow2 12))))
let normalize5_first_part_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (f0,f1,f2,f3,f4) = f in
let t = normalize_weak5 f in
let (t0,t1,t2,t3,t4) = t in
normalize_weak5_lemma m f;
assert (as_nat5 t == as_nat5 f - v f4 / pow2 48 * S.prime);
assert (felem_fits5 t (1,1,1,1,2));
assert ((v t4 >= pow2 48 ==> v t4 % pow2 48 < pow2 12));
let x, r = minus_x_mul_pow2_256 t in
let (r0,r1,r2,r3,r4) = r in
minus_x_mul_pow2_256_lemma (1,1,1,1,2) t;
assert (as_nat5 r == as_nat5 t - v x * pow2 256);
assert (as_nat5 r == as_nat5 f - v f4 / pow2 48 * S.prime - v x * pow2 256);
assert (felem_fits5 r (1,1,1,1,1));
assert (v r4 = v t4 % pow2 48 /\ v x = v t4 / pow2 48);
LD.lemma_div_pow48 t4;
assert (if v t4 < pow2 48 then v x = 0 else v x = 1 /\ v r4 < pow2 12)
val normalize5_second_part_x_is_one_lemma: x:uint64 -> r:felem5 -> Lemma
(requires (let (r0,r1,r2,r3,r4) = r in
felem_fits5 r (1,1,1,1,1) /\ v x = 1 /\ v r4 < pow2 12))
(ensures (let k = normalize5_second_part_x x r in
as_nat5 k == as_nat5 r + v x * pow2 256 - S.prime /\
felem_fits5 k (1,1,1,1,1) /\ as_nat5 k < S.prime))
let normalize5_second_part_x_is_one_lemma x r =
LD.lemma_as_nat_bound_f4_lt_pow12 r;
assert (as_nat5 r <= pow2 220 - 1);
assert_norm (pow2 220 - 1 < S.prime);
let is_ge_p_m = is_felem_ge_prime5 r in
is_felem_ge_prime5_lemma r;
assert (v is_ge_p_m = 0);
let m_to_one = is_ge_p_m &. u64 1 in
logand_lemma is_ge_p_m (u64 1);
assert (v m_to_one = 0);
let x1 = m_to_one |. x in //1
logor_spec m_to_one x;
FStar.UInt.logor_commutative #64 (v m_to_one) (v x);
FStar.UInt.logor_lemma_1 #64 (v x);
assert (v x1 = 1);
let s = plus_x_mul_pow2_256_minus_prime x1 r in // + x * (pow2 256 - S.prime)
plus_x_mul_pow2_256_minus_prime_lemma (1,1,1,1,1) x1 r;
assert (as_nat5 s = as_nat5 r + pow2 256 - S.prime); //(v s4 >= pow2 48 ==> v s4 % pow2 48 < pow2 12)
let (s0,s1,s2,s3,s4) = s in
Math.Lemmas.pow2_double_sum 12;
assert (v s4 < pow2 13);
let x2, k = minus_x_mul_pow2_256 s in // - s4 / pow2 48 * pow2 256
minus_x_mul_pow2_256_lemma (1,1,1,1,2) s;
assert (felem_fits5 k (1,1,1,1,1));
assert (as_nat5 k = as_nat5 s - v s4 / pow2 48 * pow2 256);
LD.lemma_div_pow48 s4;
assert (as_nat5 k = as_nat5 s);
assert (as_nat5 k < pow2 220 + pow2 256 - S.prime);
assert_norm (pow2 220 + pow2 256 - S.prime < S.prime)
val normalize5_second_part_x_is_zero_lemma: x:uint64 -> r:felem5 -> Lemma
(requires (let (r0,r1,r2,r3,r4) = r in
felem_fits5 r (1,1,1,1,1) /\ v x = 0))
(ensures (let k = normalize5_second_part_x x r in
as_nat5 k == (if as_nat5 r < S.prime then as_nat5 r else as_nat5 r - S.prime) /\
felem_fits5 k (1,1,1,1,1) /\ as_nat5 k < S.prime))
let normalize5_second_part_x_is_zero_lemma x r =
let is_ge_p_m = is_felem_ge_prime5 r in
is_felem_ge_prime5_lemma r;
assert (if v is_ge_p_m = ones_v U64
then (as_nat5 r >= S.prime) else as_nat5 r < S.prime);
let m_to_one = is_ge_p_m &. u64 1 in
logand_lemma is_ge_p_m (u64 1);
assert (if v is_ge_p_m = ones_v U64 then v m_to_one = 1 else v m_to_one = 0);
let x1 = m_to_one |. x in //1
logor_spec m_to_one x;
FStar.UInt.logor_lemma_1 #64 (v m_to_one);
assert (v x1 = v m_to_one);
assert (if v x1 = 1 then (as_nat5 r >= S.prime) else as_nat5 r < S.prime);
let s = plus_x_mul_pow2_256_minus_prime x1 r in // + x1 * (pow2 256 - S.prime)
plus_x_mul_pow2_256_minus_prime_lemma (1,1,1,1,1) x1 r;
assert (as_nat5 s = as_nat5 r + v x1 * (pow2 256 - S.prime)); //(v s4 >= pow2 48 ==> v s4 % pow2 48 < pow2 12)
let (s0,s1,s2,s3,s4) = s in
let x2, k = minus_x_mul_pow2_256 s in // - s4 / pow2 48 * pow2 256
minus_x_mul_pow2_256_lemma (1,1,1,1,2) s;
assert (felem_fits5 k (1,1,1,1,1));
assert (as_nat5 k = as_nat5 s - v s4 / pow2 48 * pow2 256);
if v x1 = 0 then begin
assert (as_nat5 s = as_nat5 r);
LD.as_nat_inj s r;
assert (felem_fits_last1 s4 1);
Math.Lemmas.small_div (v s4) (pow2 48);
assert (as_nat5 k = as_nat5 r) end
else begin
assert (as_nat5 s = as_nat5 r + pow2 256 - S.prime);
assert (as_nat5 s >= pow2 256);
assert (v s4 >= pow2 48);
LD.lemma_div_pow48 s4;
assert (as_nat5 k = as_nat5 r - S.prime) end
val lemma_a_minus_b_n_c_n_k (k a b c:nat) (n:pos) : Lemma
(requires k < n /\ k == a - b * n - c * n)
(ensures k == a % n)
let lemma_a_minus_b_n_c_n_k k a b c n =
Math.Lemmas.lemma_mod_sub (a - b * n) n c;
Math.Lemmas.lemma_mod_sub a n b;
Math.Lemmas.small_mod k n
val normalize5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let r = normalize5 f in
as_nat5 r == as_nat5 f % S.prime /\
felem_fits5 r (1,1,1,1,1))) | false | false | Hacl.Spec.K256.Field52.Lemmas2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val normalize5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let r = normalize5 f in
as_nat5 r == as_nat5 f % S.prime /\
felem_fits5 r (1,1,1,1,1))) | [] | Hacl.Spec.K256.Field52.Lemmas2.normalize5_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.Lemmas2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | m: Hacl.Spec.K256.Field52.Definitions.scale64_5 -> f: Hacl.Spec.K256.Field52.Definitions.felem5
-> FStar.Pervasives.Lemma
(requires
(let _ = m in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ m0 m1 m2 m3 _ = _ in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
Hacl.Spec.K256.Field52.Definitions.felem_fits5 f m)
<:
Type0))
(ensures
(let r = Hacl.Spec.K256.Field52.normalize5 f in
Hacl.Spec.K256.Field52.Definitions.as_nat5 r ==
Hacl.Spec.K256.Field52.Definitions.as_nat5 f % Spec.K256.PointOps.prime /\
Hacl.Spec.K256.Field52.Definitions.felem_fits5 r (1, 1, 1, 1, 1))) | {
"end_col": 84,
"end_line": 382,
"start_col": 26,
"start_line": 364
} |
FStar.Pervasives.Lemma | val normalize5_second_part_x_is_zero_lemma: x:uint64 -> r:felem5 -> Lemma
(requires (let (r0,r1,r2,r3,r4) = r in
felem_fits5 r (1,1,1,1,1) /\ v x = 0))
(ensures (let k = normalize5_second_part_x x r in
as_nat5 k == (if as_nat5 r < S.prime then as_nat5 r else as_nat5 r - S.prime) /\
felem_fits5 k (1,1,1,1,1) /\ as_nat5 k < S.prime)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Definitions.Lemmas",
"short_module": "LD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.MathLemmas",
"short_module": "ML"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let normalize5_second_part_x_is_zero_lemma x r =
let is_ge_p_m = is_felem_ge_prime5 r in
is_felem_ge_prime5_lemma r;
assert (if v is_ge_p_m = ones_v U64
then (as_nat5 r >= S.prime) else as_nat5 r < S.prime);
let m_to_one = is_ge_p_m &. u64 1 in
logand_lemma is_ge_p_m (u64 1);
assert (if v is_ge_p_m = ones_v U64 then v m_to_one = 1 else v m_to_one = 0);
let x1 = m_to_one |. x in //1
logor_spec m_to_one x;
FStar.UInt.logor_lemma_1 #64 (v m_to_one);
assert (v x1 = v m_to_one);
assert (if v x1 = 1 then (as_nat5 r >= S.prime) else as_nat5 r < S.prime);
let s = plus_x_mul_pow2_256_minus_prime x1 r in // + x1 * (pow2 256 - S.prime)
plus_x_mul_pow2_256_minus_prime_lemma (1,1,1,1,1) x1 r;
assert (as_nat5 s = as_nat5 r + v x1 * (pow2 256 - S.prime)); //(v s4 >= pow2 48 ==> v s4 % pow2 48 < pow2 12)
let (s0,s1,s2,s3,s4) = s in
let x2, k = minus_x_mul_pow2_256 s in // - s4 / pow2 48 * pow2 256
minus_x_mul_pow2_256_lemma (1,1,1,1,2) s;
assert (felem_fits5 k (1,1,1,1,1));
assert (as_nat5 k = as_nat5 s - v s4 / pow2 48 * pow2 256);
if v x1 = 0 then begin
assert (as_nat5 s = as_nat5 r);
LD.as_nat_inj s r;
assert (felem_fits_last1 s4 1);
Math.Lemmas.small_div (v s4) (pow2 48);
assert (as_nat5 k = as_nat5 r) end
else begin
assert (as_nat5 s = as_nat5 r + pow2 256 - S.prime);
assert (as_nat5 s >= pow2 256);
assert (v s4 >= pow2 48);
LD.lemma_div_pow48 s4;
assert (as_nat5 k = as_nat5 r - S.prime) end | val normalize5_second_part_x_is_zero_lemma: x:uint64 -> r:felem5 -> Lemma
(requires (let (r0,r1,r2,r3,r4) = r in
felem_fits5 r (1,1,1,1,1) /\ v x = 0))
(ensures (let k = normalize5_second_part_x x r in
as_nat5 k == (if as_nat5 r < S.prime then as_nat5 r else as_nat5 r - S.prime) /\
felem_fits5 k (1,1,1,1,1) /\ as_nat5 k < S.prime))
let normalize5_second_part_x_is_zero_lemma x r = | false | null | true | let is_ge_p_m = is_felem_ge_prime5 r in
is_felem_ge_prime5_lemma r;
assert (if v is_ge_p_m = ones_v U64 then (as_nat5 r >= S.prime) else as_nat5 r < S.prime);
let m_to_one = is_ge_p_m &. u64 1 in
logand_lemma is_ge_p_m (u64 1);
assert (if v is_ge_p_m = ones_v U64 then v m_to_one = 1 else v m_to_one = 0);
let x1 = m_to_one |. x in
logor_spec m_to_one x;
FStar.UInt.logor_lemma_1 #64 (v m_to_one);
assert (v x1 = v m_to_one);
assert (if v x1 = 1 then (as_nat5 r >= S.prime) else as_nat5 r < S.prime);
let s = plus_x_mul_pow2_256_minus_prime x1 r in
plus_x_mul_pow2_256_minus_prime_lemma (1, 1, 1, 1, 1) x1 r;
assert (as_nat5 s = as_nat5 r + v x1 * (pow2 256 - S.prime));
let s0, s1, s2, s3, s4 = s in
let x2, k = minus_x_mul_pow2_256 s in
minus_x_mul_pow2_256_lemma (1, 1, 1, 1, 2) s;
assert (felem_fits5 k (1, 1, 1, 1, 1));
assert (as_nat5 k = as_nat5 s - (v s4 / pow2 48) * pow2 256);
if v x1 = 0
then
(assert (as_nat5 s = as_nat5 r);
LD.as_nat_inj s r;
assert (felem_fits_last1 s4 1);
Math.Lemmas.small_div (v s4) (pow2 48);
assert (as_nat5 k = as_nat5 r))
else
(assert (as_nat5 s = as_nat5 r + pow2 256 - S.prime);
assert (as_nat5 s >= pow2 256);
assert (v s4 >= pow2 48);
LD.lemma_div_pow48 s4;
assert (as_nat5 k = as_nat5 r - S.prime)) | {
"checked_file": "Hacl.Spec.K256.Field52.Lemmas2.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.MathLemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.Lemmas2.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.uint64",
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Prims.op_Equality",
"Prims.int",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims._assert",
"Prims.b2t",
"Prims.nat",
"Hacl.Spec.K256.Field52.Definitions.as_nat5",
"Prims.unit",
"FStar.Math.Lemmas.small_div",
"Prims.pow2",
"Hacl.Spec.K256.Field52.Definitions.felem_fits_last1",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.as_nat_inj",
"Prims.bool",
"Prims.op_Subtraction",
"Spec.K256.PointOps.prime",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.lemma_div_pow48",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.op_Division",
"Hacl.Spec.K256.Field52.Definitions.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Hacl.Spec.K256.Field52.Lemmas2.minus_x_mul_pow2_256_lemma",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Hacl.Spec.K256.Field52.minus_x_mul_pow2_256",
"Hacl.Spec.K256.Field52.Lemmas2.plus_x_mul_pow2_256_minus_prime_lemma",
"Hacl.Spec.K256.Field52.plus_x_mul_pow2_256_minus_prime",
"Prims.op_LessThan",
"Lib.IntTypes.range_t",
"FStar.UInt.logor_lemma_1",
"Lib.IntTypes.logor_spec",
"Lib.IntTypes.op_Bar_Dot",
"Lib.IntTypes.ones_v",
"Lib.IntTypes.logand_lemma",
"Lib.IntTypes.u64",
"Lib.IntTypes.op_Amp_Dot",
"Hacl.Spec.K256.Field52.Lemmas2.is_felem_ge_prime5_lemma",
"Hacl.Spec.K256.Field52.is_felem_ge_prime5"
] | [] | module Hacl.Spec.K256.Field52.Lemmas2
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
include Hacl.Spec.K256.Field52
module ML = Hacl.Spec.K256.MathLemmas
module LD = Hacl.Spec.K256.Field52.Definitions.Lemmas
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
/// Normalize-weak
val minus_x_mul_pow2_256_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires felem_fits5 f m)
(ensures
(let x, r = minus_x_mul_pow2_256 f in
let (r0,r1,r2,r3,r4) = r in
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
v x < pow2 16 /\ v x = v t4 / pow2 48 /\
v r4 = v t4 % pow2 48 /\
as_nat5 r == as_nat5 f - v x * pow2 256 /\
felem_fits5 r (m0,m1,m2,m3,1)))
let minus_x_mul_pow2_256_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
let x = t4 >>. 48ul in let t4' = t4 &. mask48 in
LD.lemma_mask48 t4;
let r = (t0,t1,t2,t3,t4') in
calc (==) { // as_nat5 f
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + v t4 * pow208;
(==) { Math.Lemmas.euclidean_division_definition (v t4) (pow2 48) }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48 + v t4 % pow2 48) * pow208;
(==) { Math.Lemmas.distributivity_add_left (v t4 / pow2 48 * pow2 48) (v t4 % pow2 48) pow208 }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48) * pow208 + (v t4 % pow2 48) * pow208;
(==) { }
(v x * pow2 48) * pow208 + as_nat5 r;
(==) { Math.Lemmas.paren_mul_right (v x) (pow2 48) pow208; Math.Lemmas.pow2_plus 48 208 }
v x * pow2 256 + as_nat5 r;
};
Math.Lemmas.lemma_div_lt (v t4) 64 48
val carry_round_after_last_carry_mod_prime5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m1 + 1 <= 4096 /\ m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f (m0,m1,m2,m3,1)))
(ensures (let r = carry_round5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let carry_round_after_last_carry_mod_prime5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in //(m0,m1,m2,m3,1)
let t1' = t1 +. (t0 >>. 52ul) in let t0' = t0 &. mask52 in
LD.lemma_carry52 m1 m0 t1 t0;
assert (felem_fits1 t1' (m1 + 1));
assert (felem_fits1 t0' 1);
assert (v t0' = v t0 % pow2 52);
assert (v t1' = v t1 + v t0 / pow2 52);
let t2' = t2 +. (t1' >>. 52ul) in let t1'' = t1' &. mask52 in
LD.lemma_carry52 m2 (m1 + 1) t2 t1';
assert (felem_fits1 t2' (m2 + 1));
assert (felem_fits1 t1'' 1);
assert (v t1'' = v t1' % pow2 52);
assert (v t2' = v t2 + v t1' / pow2 52);
let t3' = t3 +. (t2' >>. 52ul) in let t2'' = t2' &. mask52 in
LD.lemma_carry52 m3 (m2 + 1) t3 t2';
assert (felem_fits1 t3' (m3 + 1));
assert (felem_fits1 t2'' 1);
assert (v t2'' = v t2' % pow2 52);
assert (v t3' = v t3 + v t2' / pow2 52);
let t4' = t4 +. (t3' >>. 52ul) in let t3'' = t3' &. mask52 in
LD.lemma_carry_last52 m4 (m3 + 1) t4 t3';
assert (felem_fits_last1 t4' (m4 + 1));
assert (felem_fits1 t3'' 1);
assert (v t3'' = v t3' % pow2 52);
assert (v t4' = v t4 + v t3' / pow2 52);
LD.carry_last_small_mod_lemma t4 t3';
ML.lemma_simplify_carry_round (v t0) (v t1) (v t2) (v t3) (v t4);
let r = carry_round5 f in
assert ((t0',t1'',t2'',t3'',t4') == r);
assert (as_nat5 r == as_nat5 f)
val plus_x_mul_pow2_256_minus_prime_lemma: m:scale64_5 -> x:uint64 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\ m4 = 1 /\
felem_fits5 f m /\ v x < pow2 16))
(ensures
(let r = plus_x_mul_pow2_256_minus_prime x f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime) /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let plus_x_mul_pow2_256_minus_prime_lemma m x f =
let (t0,t1,t2,t3,t4) = f in
let (m0,m1,m2,m3,m4) = m in
let t0' = t0 +. x *. u64 0x1000003D1 in
assert (v x < pow2 16);
Math.Lemmas.lemma_mult_lt_right 0x1000003D1 (v x) (pow2 16);
assert_norm (pow2 16 * 0x1000003D1 < max52);
assert (v t0 + v x * 0x1000003D1 < (m0 + 1) * max52);
Math.Lemmas.lemma_mult_le_right max52 (m0 + 1) 4096;
assert_norm (4096 * max52 < pow2 64);
Math.Lemmas.small_mod (v t0 + v x * 0x1000003D1) (pow2 64);
assert (v t0' = v t0 + v x * 0x1000003D1);
assert (felem_fits1 t0' (m0 + 1));
let r = carry_round5 (t0',t1,t2,t3,t4) in
carry_round_after_last_carry_mod_prime5_lemma (m0+1,m1,m2,m3,m4) (t0',t1,t2,t3,t4);
assert (as_nat5 r == as_nat5 (t0',t1,t2,t3,t4));
LD.lemma_pow2_256_minus_prime ();
assert (as_nat5 r == as_nat5 f + v x * (pow2 256 - S.prime))
val normalize_weak5_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let r = normalize_weak5 f in
let (r0,r1,r2,r3,r4) = r in
let (t0,t1,t2,t3,t4) = f in
as_nat5 r == as_nat5 f - v t4 / pow2 48 * S.prime /\ felem_fits5 r (1,1,1,1,2) /\
v r4 < v t4 + pow2 12 /\ (v r4 >= pow2 48 ==> v r4 % pow2 48 < pow2 12)))
let normalize_weak5_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let x, f1 = minus_x_mul_pow2_256 f in
minus_x_mul_pow2_256_lemma m f;
assert (as_nat5 f1 == as_nat5 f - v x * pow2 256);
assert (felem_fits5 f1 (m0,m1,m2,m3,1));
let f2 = plus_x_mul_pow2_256_minus_prime x f1 in
plus_x_mul_pow2_256_minus_prime_lemma (m0,m1,m2,m3,1) x f1;
assert (as_nat5 f2 == as_nat5 f1 + v x * (pow2 256 - S.prime));
assert (felem_fits5 f2 (1,1,1,1,2));
assert (f2 == normalize_weak5 f);
Math.Lemmas.distributivity_sub_right (v x) (pow2 256) S.prime;
assert (as_nat5 f2 == as_nat5 f - v x * S.prime)
/// Normalize
#push-options "--ifuel 1"
val is_felem_ge_prime5_lemma: f:felem5 -> Lemma
(requires felem_fits5 f (1,1,1,1,1))
(ensures (let is_m = is_felem_ge_prime5 f in
(v is_m = 0 \/ v is_m = ones_v U64) /\
(if v is_m = ones_v U64 then (as_nat5 f >= S.prime) else (as_nat5 f < S.prime))))
let is_felem_ge_prime5_lemma f = ()
#pop-options
// let (f0,f1,f2,f3,f4) = f in
// let m4 = eq_mask f4 mask48 in
// eq_mask_lemma f4 mask48;
// assert (if v f4 = v mask48 then v m4 = ones_v U64 else v m4 = 0);
// let m3 = eq_mask f3 mask52 in
// eq_mask_lemma f3 mask52;
// assert (if v f3 = v mask52 then v m3 = ones_v U64 else v m3 = 0);
// let m2 = eq_mask f2 mask52 in
// eq_mask_lemma f2 mask52;
// assert (if v f2 = v mask52 then v m2 = ones_v U64 else v m2 = 0);
// let m1 = eq_mask f1 mask52 in
// eq_mask_lemma f1 mask52;
// assert (if v f1 = v mask52 then v m1 = ones_v U64 else v m1 = 0);
// let m0 = gte_mask f0 (u64 0xffffefffffc2f) in
// gte_mask_lemma f0 (u64 0xffffefffffc2f);
// assert (if v f0 >= 0xffffefffffc2f then v m0 = ones_v U64 else v m0 = 0);
// let m = m0 &. m1 &. m2 &. m3 &. m4 in ()
// if v m4 = 0 then
// logand_zeros (m0 &. m1 &. m2 &. m3)
// else begin
// logand_ones (m0 &. m1 &. m2 &. m3) end
noextract
let normalize5_first_part (f0,f1,f2,f3,f4) =
let (t0,t1,t2,t3,t4) = normalize_weak5 (f0,f1,f2,f3,f4) in
let x, (r0,r1,r2,r3,r4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
x, (r0,r1,r2,r3,r4)
noextract
let normalize5_second_part_x (x:uint64) (r0,r1,r2,r3,r4) : felem5 =
let is_ge_p_m = is_felem_ge_prime5 (r0,r1,r2,r3,r4) in // as_nat r >= S.prime
let m_to_one = is_ge_p_m &. u64 1 in
let x1 = m_to_one |. x in
let (s0,s1,s2,s3,s4) = plus_x_mul_pow2_256_minus_prime x1 (r0,r1,r2,r3,r4) in
let x2, (k0,k1,k2,k3,k4) = minus_x_mul_pow2_256 (s0,s1,s2,s3,s4) in
(k0,k1,k2,k3,k4)
val normalize5_first_part_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires (let (m0,m1,m2,m3,m4) = m in
m0 + 1 <= 4096 /\ m1 + 1 <= 4096 /\
m2 + 1 <= 4096 /\ m3 + 1 <= 4096 /\
felem_fits5 f m))
(ensures (let x, r = normalize5_first_part f in
let (f0,f1,f2,f3,f4) = f in
let (r0,r1,r2,r3,r4) = r in
as_nat5 r == as_nat5 f - v f4 / pow2 48 * S.prime - v x * pow2 256 /\
felem_fits5 r (1,1,1,1,1) /\ (v x = 0 \/ (v x = 1 /\ v r4 < pow2 12))))
let normalize5_first_part_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (f0,f1,f2,f3,f4) = f in
let t = normalize_weak5 f in
let (t0,t1,t2,t3,t4) = t in
normalize_weak5_lemma m f;
assert (as_nat5 t == as_nat5 f - v f4 / pow2 48 * S.prime);
assert (felem_fits5 t (1,1,1,1,2));
assert ((v t4 >= pow2 48 ==> v t4 % pow2 48 < pow2 12));
let x, r = minus_x_mul_pow2_256 t in
let (r0,r1,r2,r3,r4) = r in
minus_x_mul_pow2_256_lemma (1,1,1,1,2) t;
assert (as_nat5 r == as_nat5 t - v x * pow2 256);
assert (as_nat5 r == as_nat5 f - v f4 / pow2 48 * S.prime - v x * pow2 256);
assert (felem_fits5 r (1,1,1,1,1));
assert (v r4 = v t4 % pow2 48 /\ v x = v t4 / pow2 48);
LD.lemma_div_pow48 t4;
assert (if v t4 < pow2 48 then v x = 0 else v x = 1 /\ v r4 < pow2 12)
val normalize5_second_part_x_is_one_lemma: x:uint64 -> r:felem5 -> Lemma
(requires (let (r0,r1,r2,r3,r4) = r in
felem_fits5 r (1,1,1,1,1) /\ v x = 1 /\ v r4 < pow2 12))
(ensures (let k = normalize5_second_part_x x r in
as_nat5 k == as_nat5 r + v x * pow2 256 - S.prime /\
felem_fits5 k (1,1,1,1,1) /\ as_nat5 k < S.prime))
let normalize5_second_part_x_is_one_lemma x r =
LD.lemma_as_nat_bound_f4_lt_pow12 r;
assert (as_nat5 r <= pow2 220 - 1);
assert_norm (pow2 220 - 1 < S.prime);
let is_ge_p_m = is_felem_ge_prime5 r in
is_felem_ge_prime5_lemma r;
assert (v is_ge_p_m = 0);
let m_to_one = is_ge_p_m &. u64 1 in
logand_lemma is_ge_p_m (u64 1);
assert (v m_to_one = 0);
let x1 = m_to_one |. x in //1
logor_spec m_to_one x;
FStar.UInt.logor_commutative #64 (v m_to_one) (v x);
FStar.UInt.logor_lemma_1 #64 (v x);
assert (v x1 = 1);
let s = plus_x_mul_pow2_256_minus_prime x1 r in // + x * (pow2 256 - S.prime)
plus_x_mul_pow2_256_minus_prime_lemma (1,1,1,1,1) x1 r;
assert (as_nat5 s = as_nat5 r + pow2 256 - S.prime); //(v s4 >= pow2 48 ==> v s4 % pow2 48 < pow2 12)
let (s0,s1,s2,s3,s4) = s in
Math.Lemmas.pow2_double_sum 12;
assert (v s4 < pow2 13);
let x2, k = minus_x_mul_pow2_256 s in // - s4 / pow2 48 * pow2 256
minus_x_mul_pow2_256_lemma (1,1,1,1,2) s;
assert (felem_fits5 k (1,1,1,1,1));
assert (as_nat5 k = as_nat5 s - v s4 / pow2 48 * pow2 256);
LD.lemma_div_pow48 s4;
assert (as_nat5 k = as_nat5 s);
assert (as_nat5 k < pow2 220 + pow2 256 - S.prime);
assert_norm (pow2 220 + pow2 256 - S.prime < S.prime)
val normalize5_second_part_x_is_zero_lemma: x:uint64 -> r:felem5 -> Lemma
(requires (let (r0,r1,r2,r3,r4) = r in
felem_fits5 r (1,1,1,1,1) /\ v x = 0))
(ensures (let k = normalize5_second_part_x x r in
as_nat5 k == (if as_nat5 r < S.prime then as_nat5 r else as_nat5 r - S.prime) /\
felem_fits5 k (1,1,1,1,1) /\ as_nat5 k < S.prime)) | false | false | Hacl.Spec.K256.Field52.Lemmas2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val normalize5_second_part_x_is_zero_lemma: x:uint64 -> r:felem5 -> Lemma
(requires (let (r0,r1,r2,r3,r4) = r in
felem_fits5 r (1,1,1,1,1) /\ v x = 0))
(ensures (let k = normalize5_second_part_x x r in
as_nat5 k == (if as_nat5 r < S.prime then as_nat5 r else as_nat5 r - S.prime) /\
felem_fits5 k (1,1,1,1,1) /\ as_nat5 k < S.prime)) | [] | Hacl.Spec.K256.Field52.Lemmas2.normalize5_second_part_x_is_zero_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.Lemmas2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Lib.IntTypes.uint64 -> r: Hacl.Spec.K256.Field52.Definitions.felem5
-> FStar.Pervasives.Lemma
(requires
(let _ = r in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ _ = _ in
Hacl.Spec.K256.Field52.Definitions.felem_fits5 r (1, 1, 1, 1, 1) /\ Lib.IntTypes.v x = 0
)
<:
Type0))
(ensures
(let k = Hacl.Spec.K256.Field52.Lemmas2.normalize5_second_part_x x r in
Hacl.Spec.K256.Field52.Definitions.as_nat5 k ==
(match Hacl.Spec.K256.Field52.Definitions.as_nat5 r < Spec.K256.PointOps.prime with
| true -> Hacl.Spec.K256.Field52.Definitions.as_nat5 r
| _ -> Hacl.Spec.K256.Field52.Definitions.as_nat5 r - Spec.K256.PointOps.prime) /\
Hacl.Spec.K256.Field52.Definitions.felem_fits5 k (1, 1, 1, 1, 1) /\
Hacl.Spec.K256.Field52.Definitions.as_nat5 k < Spec.K256.PointOps.prime)) | {
"end_col": 48,
"end_line": 342,
"start_col": 48,
"start_line": 304
} |
FStar.Pervasives.Lemma | val minus_x_mul_pow2_256_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires felem_fits5 f m)
(ensures
(let x, r = minus_x_mul_pow2_256 f in
let (r0,r1,r2,r3,r4) = r in
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
v x < pow2 16 /\ v x = v t4 / pow2 48 /\
v r4 = v t4 % pow2 48 /\
as_nat5 r == as_nat5 f - v x * pow2 256 /\
felem_fits5 r (m0,m1,m2,m3,1))) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Definitions.Lemmas",
"short_module": "LD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.MathLemmas",
"short_module": "ML"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let minus_x_mul_pow2_256_lemma m f =
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
let x = t4 >>. 48ul in let t4' = t4 &. mask48 in
LD.lemma_mask48 t4;
let r = (t0,t1,t2,t3,t4') in
calc (==) { // as_nat5 f
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + v t4 * pow208;
(==) { Math.Lemmas.euclidean_division_definition (v t4) (pow2 48) }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48 + v t4 % pow2 48) * pow208;
(==) { Math.Lemmas.distributivity_add_left (v t4 / pow2 48 * pow2 48) (v t4 % pow2 48) pow208 }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + (v t4 / pow2 48 * pow2 48) * pow208 + (v t4 % pow2 48) * pow208;
(==) { }
(v x * pow2 48) * pow208 + as_nat5 r;
(==) { Math.Lemmas.paren_mul_right (v x) (pow2 48) pow208; Math.Lemmas.pow2_plus 48 208 }
v x * pow2 256 + as_nat5 r;
};
Math.Lemmas.lemma_div_lt (v t4) 64 48 | val minus_x_mul_pow2_256_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires felem_fits5 f m)
(ensures
(let x, r = minus_x_mul_pow2_256 f in
let (r0,r1,r2,r3,r4) = r in
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
v x < pow2 16 /\ v x = v t4 / pow2 48 /\
v r4 = v t4 % pow2 48 /\
as_nat5 r == as_nat5 f - v x * pow2 256 /\
felem_fits5 r (m0,m1,m2,m3,1)))
let minus_x_mul_pow2_256_lemma m f = | false | null | true | let m0, m1, m2, m3, m4 = m in
let t0, t1, t2, t3, t4 = f in
let x = t4 >>. 48ul in
let t4' = t4 &. mask48 in
LD.lemma_mask48 t4;
let r = (t0, t1, t2, t3, t4') in
calc ( == ) {
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + v t4 * pow208;
( == ) { Math.Lemmas.euclidean_division_definition (v t4) (pow2 48) }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 +
((v t4 / pow2 48) * pow2 48 + v t4 % pow2 48) * pow208;
( == ) { Math.Lemmas.distributivity_add_left ((v t4 / pow2 48) * pow2 48) (v t4 % pow2 48) pow208 }
v t0 + v t1 * pow52 + v t2 * pow104 + v t3 * pow156 + ((v t4 / pow2 48) * pow2 48) * pow208 +
(v t4 % pow2 48) * pow208;
( == ) { () }
(v x * pow2 48) * pow208 + as_nat5 r;
( == ) { (Math.Lemmas.paren_mul_right (v x) (pow2 48) pow208;
Math.Lemmas.pow2_plus 48 208) }
v x * pow2 256 + as_nat5 r;
};
Math.Lemmas.lemma_div_lt (v t4) 64 48 | {
"checked_file": "Hacl.Spec.K256.Field52.Lemmas2.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.MathLemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.Lemmas2.fst"
} | [
"lemma"
] | [
"Hacl.Spec.K256.Field52.Definitions.scale64_5",
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Prims.nat",
"Lib.IntTypes.uint64",
"FStar.Math.Lemmas.lemma_div_lt",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Hacl.Spec.K256.Field52.Definitions.pow52",
"Hacl.Spec.K256.Field52.Definitions.pow104",
"Hacl.Spec.K256.Field52.Definitions.pow156",
"Hacl.Spec.K256.Field52.Definitions.pow208",
"Prims.pow2",
"Hacl.Spec.K256.Field52.Definitions.as_nat5",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"Prims.op_Division",
"Prims.op_Modulus",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Lemmas.euclidean_division_definition",
"Prims.squash",
"FStar.Math.Lemmas.distributivity_add_left",
"FStar.Math.Lemmas.pow2_plus",
"FStar.Math.Lemmas.paren_mul_right",
"FStar.Pervasives.Native.tuple5",
"Lib.IntTypes.int_t",
"FStar.Pervasives.Native.Mktuple5",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.lemma_mask48",
"Lib.IntTypes.op_Amp_Dot",
"Hacl.Spec.K256.Field52.Definitions.mask48",
"Lib.IntTypes.op_Greater_Greater_Dot",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.Spec.K256.Field52.Lemmas2
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
include Hacl.Spec.K256.Field52
module ML = Hacl.Spec.K256.MathLemmas
module LD = Hacl.Spec.K256.Field52.Definitions.Lemmas
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
/// Normalize-weak
val minus_x_mul_pow2_256_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires felem_fits5 f m)
(ensures
(let x, r = minus_x_mul_pow2_256 f in
let (r0,r1,r2,r3,r4) = r in
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
v x < pow2 16 /\ v x = v t4 / pow2 48 /\
v r4 = v t4 % pow2 48 /\
as_nat5 r == as_nat5 f - v x * pow2 256 /\
felem_fits5 r (m0,m1,m2,m3,1))) | false | false | Hacl.Spec.K256.Field52.Lemmas2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val minus_x_mul_pow2_256_lemma: m:scale64_5 -> f:felem5 -> Lemma
(requires felem_fits5 f m)
(ensures
(let x, r = minus_x_mul_pow2_256 f in
let (r0,r1,r2,r3,r4) = r in
let (m0,m1,m2,m3,m4) = m in
let (t0,t1,t2,t3,t4) = f in
v x < pow2 16 /\ v x = v t4 / pow2 48 /\
v r4 = v t4 % pow2 48 /\
as_nat5 r == as_nat5 f - v x * pow2 256 /\
felem_fits5 r (m0,m1,m2,m3,1))) | [] | Hacl.Spec.K256.Field52.Lemmas2.minus_x_mul_pow2_256_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.Lemmas2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | m: Hacl.Spec.K256.Field52.Definitions.scale64_5 -> f: Hacl.Spec.K256.Field52.Definitions.felem5
-> FStar.Pervasives.Lemma (requires Hacl.Spec.K256.Field52.Definitions.felem_fits5 f m)
(ensures
(let _ = Hacl.Spec.K256.Field52.minus_x_mul_pow2_256 f in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ x r = _ in
let _ = r in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ r4 = _ in
let _ = m in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ m0 m1 m2 m3 _ = _ in
let _ = f in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ t4 = _ in
Lib.IntTypes.v x < Prims.pow2 16 /\
Lib.IntTypes.v x = Lib.IntTypes.v t4 / Prims.pow2 48 /\
Lib.IntTypes.v r4 = Lib.IntTypes.v t4 % Prims.pow2 48 /\
Hacl.Spec.K256.Field52.Definitions.as_nat5 r ==
Hacl.Spec.K256.Field52.Definitions.as_nat5 f - Lib.IntTypes.v x * Prims.pow2 256 /\
Hacl.Spec.K256.Field52.Definitions.felem_fits5 r (m0, m1, m2, m3, 1))
<:
Type0)
<:
Type0)
<:
Type0)
<:
Type0)) | {
"end_col": 39,
"end_line": 50,
"start_col": 36,
"start_line": 30
} |
Prims.Tot | val snd (x: tuple2 'a 'b) : 'b | [
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
}
] | false | let snd (x: tuple2 'a 'b) : 'b = Mktuple2?._2 x | val snd (x: tuple2 'a 'b) : 'b
let snd (x: tuple2 'a 'b) : 'b = | false | null | false | Mktuple2?._2 x | {
"checked_file": "FStar.Pervasives.Native.fst.checked",
"dependencies": [
"prims.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Pervasives.Native.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.__proj__Mktuple2__item___2"
] | [] | (*
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.Pervasives.Native
(* This is a file from the core library, dependencies must be explicit *)
open Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides several basic types in F* that enjoy some special
/// status in extraction. For instance, the tuple type below is
/// compiled to OCaml's tuple type, rather than to a F*-defined
/// inductive type. See ulib/ml/FStar_Pervasives_Native.ml
///
(** [option a] represents either [Some a]-value or a non-informative [None]. *)
type option (a: Type) =
| None : option a
| Some : v: a -> option a
(**** Tuples *)
/// Aside from special support in extraction, the tuple types have
/// special syntax in F*.
///
/// For instance, rather than [tupleN a1 ... aN],
/// we usually write [a1 & ... & aN] or [a1 * ... * aN].
///
/// The latter notation is more common for those coming to F* from
/// OCaml or F#. However, the [*] also clashes with the multiplication
/// operator on integers define in FStar.Mul. For this reason, we now
/// prefer to use the [&] notation, though there are still many uses
/// of [*] remaining.
///
/// Tuple values are introduced using as [a1, ..., an], rather than
/// [MktupleN a1 ... aN].
///
/// We define tuples up to a fixed arity of 14. We have considered
/// splitting this module into 14 different modules, one for each
/// tuple type rather than eagerly including 14-tuples in the
/// dependence graph of all programs.
(** Pairs: [tuple2 a b] is can be written either as [a * b], for
notation compatible with OCaml's. Or, better, as [a & b]. *)
type tuple2 'a 'b = | Mktuple2 : _1: 'a -> _2: 'b -> tuple2 'a 'b
(** The fst and snd projections on pairs are very common *) | false | false | FStar.Pervasives.Native.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val snd (x: tuple2 'a 'b) : 'b | [] | FStar.Pervasives.Native.snd | {
"file_name": "ulib/FStar.Pervasives.Native.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: ('a * 'b) -> 'b | {
"end_col": 47,
"end_line": 63,
"start_col": 33,
"start_line": 63
} |
Prims.Tot | val fst (x: tuple2 'a 'b) : 'a | [
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
}
] | false | let fst (x: tuple2 'a 'b) : 'a = Mktuple2?._1 x | val fst (x: tuple2 'a 'b) : 'a
let fst (x: tuple2 'a 'b) : 'a = | false | null | false | Mktuple2?._1 x | {
"checked_file": "FStar.Pervasives.Native.fst.checked",
"dependencies": [
"prims.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Pervasives.Native.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.__proj__Mktuple2__item___1"
] | [] | (*
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.Pervasives.Native
(* This is a file from the core library, dependencies must be explicit *)
open Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides several basic types in F* that enjoy some special
/// status in extraction. For instance, the tuple type below is
/// compiled to OCaml's tuple type, rather than to a F*-defined
/// inductive type. See ulib/ml/FStar_Pervasives_Native.ml
///
(** [option a] represents either [Some a]-value or a non-informative [None]. *)
type option (a: Type) =
| None : option a
| Some : v: a -> option a
(**** Tuples *)
/// Aside from special support in extraction, the tuple types have
/// special syntax in F*.
///
/// For instance, rather than [tupleN a1 ... aN],
/// we usually write [a1 & ... & aN] or [a1 * ... * aN].
///
/// The latter notation is more common for those coming to F* from
/// OCaml or F#. However, the [*] also clashes with the multiplication
/// operator on integers define in FStar.Mul. For this reason, we now
/// prefer to use the [&] notation, though there are still many uses
/// of [*] remaining.
///
/// Tuple values are introduced using as [a1, ..., an], rather than
/// [MktupleN a1 ... aN].
///
/// We define tuples up to a fixed arity of 14. We have considered
/// splitting this module into 14 different modules, one for each
/// tuple type rather than eagerly including 14-tuples in the
/// dependence graph of all programs.
(** Pairs: [tuple2 a b] is can be written either as [a * b], for
notation compatible with OCaml's. Or, better, as [a & b]. *)
type tuple2 'a 'b = | Mktuple2 : _1: 'a -> _2: 'b -> tuple2 'a 'b | false | false | FStar.Pervasives.Native.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fst (x: tuple2 'a 'b) : 'a | [] | FStar.Pervasives.Native.fst | {
"file_name": "ulib/FStar.Pervasives.Native.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: ('a * 'b) -> 'a | {
"end_col": 47,
"end_line": 62,
"start_col": 33,
"start_line": 62
} |
FStar.Pervasives.Lemma | val valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos)) | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos) | val valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos)) = | false | null | true | valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos) | {
"checked_file": "LowParse.Low.VCList.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
"lemma"
] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"LowParse.Spec.VCList.parse_nlist_eq",
"LowParse.Slice.bytes_of_slice_from",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"LowParse.Low.Base.Spec.valid",
"Prims.squash",
"LowParse.Low.Base.Spec.valid_content_pos",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos)) | false | false | LowParse.Low.VCList.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos)) | [] | LowParse.Low.VCList.valid_nlist_nil_recip | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
sl: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(requires LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist 0 p) h sl pos)
(ensures
LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.VCList.parse_nlist 0 p)
h
sl
pos
[]
pos) | {
"end_col": 51,
"end_line": 39,
"start_col": 2,
"start_line": 38
} |
FStar.Pervasives.Lemma | val valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos)) | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos) | val valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos)) = | false | null | true | valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos) | {
"checked_file": "LowParse.Low.VCList.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
"lemma"
] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"LowParse.Spec.VCList.parse_nlist_eq",
"LowParse.Slice.bytes_of_slice_from",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"Prims.l_and",
"LowParse.Slice.live_slice",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"LowParse.Slice.__proj__Mkslice__item__len",
"Prims.squash",
"LowParse.Low.Base.Spec.valid_content_pos",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len)) | false | false | LowParse.Low.VCList.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos)) | [] | LowParse.Low.VCList.valid_nlist_nil | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
sl: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(requires
LowParse.Slice.live_slice h sl /\ FStar.UInt32.v pos <= FStar.UInt32.v (Mkslice?.len sl))
(ensures
LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.VCList.parse_nlist 0 p)
h
sl
pos
[]
pos) | {
"end_col": 51,
"end_line": 25,
"start_col": 2,
"start_line": 24
} |
FStar.Pervasives.Lemma | val valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ (~(valid p h sl pos))))
(ensures (~(valid (parse_nlist n p) h sl pos))) | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos | val valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ (~(valid p h sl pos))))
(ensures (~(valid (parse_nlist n p) h sl pos)))
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ (~(valid p h sl pos))))
(ensures (~(valid (parse_nlist n p) h sl pos))) = | false | null | true | Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos | {
"checked_file": "LowParse.Low.VCList.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
"lemma"
] | [
"Prims.nat",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"FStar.Classical.move_requires",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThan",
"LowParse.Low.Base.Spec.valid",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"Prims.op_Subtraction",
"LowParse.Low.Base.Spec.get_valid_pos",
"LowParse.Low.Base.Spec.valid_content_pos",
"Prims.Cons",
"LowParse.Low.Base.Spec.contents",
"LowParse.Low.VCList.valid_nlist_cons_recip",
"Prims.unit",
"Prims.op_Addition",
"LowParse.Low.VCList.valid_nlist_cons",
"Prims.l_not",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos) | false | false | LowParse.Low.VCList.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ (~(valid p h sl pos))))
(ensures (~(valid (parse_nlist n p) h sl pos))) | [] | LowParse.Low.VCList.valid_nlist_cons_not | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
n: Prims.nat ->
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
sl: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma (requires n > 0 /\ ~(LowParse.Low.Base.Spec.valid p h sl pos))
(ensures ~(LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist n p) h sl pos)) | {
"end_col": 63,
"end_line": 149,
"start_col": 2,
"start_line": 148
} |
FStar.Pervasives.Lemma | val valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos pos': U32.t)
: Lemma (requires (valid_list p h sl pos pos'))
(ensures
(let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'))
(decreases (U32.v pos' - U32.v pos)) | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
(pos' : U32.t)
: Lemma
(requires (
valid_list p h sl pos pos'
))
(ensures (
let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'
))
(decreases (U32.v pos' - U32.v pos))
= if pos = pos'
then begin
valid_list_nil p h sl pos;
valid_nlist_nil p h sl pos
end else begin
valid_list_cons_recip p h sl pos pos' ;
let pos1 = get_valid_pos p h sl pos in
valid_list_valid_nlist p h sl pos1 pos' ;
valid_nlist_cons (L.length (contents_list p h sl pos1 pos')) p h sl pos
end | val valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos pos': U32.t)
: Lemma (requires (valid_list p h sl pos pos'))
(ensures
(let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'))
(decreases (U32.v pos' - U32.v pos))
let rec valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos pos': U32.t)
: Lemma (requires (valid_list p h sl pos pos'))
(ensures
(let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'))
(decreases (U32.v pos' - U32.v pos)) = | false | null | true | if pos = pos'
then
(valid_list_nil p h sl pos;
valid_nlist_nil p h sl pos)
else
(valid_list_cons_recip p h sl pos pos';
let pos1 = get_valid_pos p h sl pos in
valid_list_valid_nlist p h sl pos1 pos';
valid_nlist_cons (L.length (contents_list p h sl pos1 pos')) p h sl pos) | {
"checked_file": "LowParse.Low.VCList.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
"lemma",
""
] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"Prims.op_Equality",
"LowParse.Low.VCList.valid_nlist_nil",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_list_nil",
"Prims.bool",
"LowParse.Low.VCList.valid_nlist_cons",
"FStar.List.Tot.Base.length",
"LowParse.Low.Base.Spec.contents_list",
"LowParse.Low.VCList.valid_list_valid_nlist",
"LowParse.Low.Base.Spec.get_valid_pos",
"LowParse.Low.Base.Spec.valid_list_cons_recip",
"LowParse.Low.Base.Spec.valid_list",
"Prims.squash",
"LowParse.Low.Base.Spec.valid_content_pos",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"Prims.list",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
#push-options "--z3rlimit 32"
inline_for_extraction
let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 : B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U64.v pos <= U64.v pos1 /\ (
if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==> valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\ valid (parse_nlist (U32.v r) p) h0 input pos1) ==> get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~ (valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@inline_let]
let stop = is_error pos2 in
[@inline_let]
let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
if is_success res
then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res
inline_for_extraction
let jump_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U32.v pos <= U32.v pos1 /\
U32.v pos1 <= U32.v input.len /\
valid (parse_nlist (U32.v n) p) h0 input pos /\ valid (parse_nlist (U32.v r) p) h0 input pos1 /\
get_valid_pos (parse_nlist (U32.v n) p) h0 input pos == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1 /\
(stop == true ==> r == 0ul)
))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
[@inline_let]
let _ =
valid_nlist_cons_recip (U32.v r) p h0 input pos1
in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
false
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
valid_nlist_nil p h0 input res
in
HST.pop_frame ();
res
#pop-options
let rec valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
k.parser_kind_low > 0 /\
k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos
))
(ensures (
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos
))
= if n = 0
then begin
valid_nlist_nil_recip p h sl pos;
valid_list_nil p h sl pos
end else begin
valid_nlist_cons_recip n p h sl pos;
let pos1 = get_valid_pos p h sl pos in
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_nlist_valid_list (n - 1) p h sl pos1;
valid_list_cons p h sl pos pos'
end
let rec valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
(pos' : U32.t)
: Lemma
(requires (
valid_list p h sl pos pos'
))
(ensures (
let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'
)) | false | false | LowParse.Low.VCList.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos pos': U32.t)
: Lemma (requires (valid_list p h sl pos pos'))
(ensures
(let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'))
(decreases (U32.v pos' - U32.v pos)) | [
"recursion"
] | LowParse.Low.VCList.valid_list_valid_nlist | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
sl: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t ->
pos': FStar.UInt32.t
-> FStar.Pervasives.Lemma (requires LowParse.Low.Base.Spec.valid_list p h sl pos pos')
(ensures
(let x = LowParse.Low.Base.Spec.contents_list p h sl pos pos' in
LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.VCList.parse_nlist (FStar.List.Tot.Base.length
x)
p)
h
sl
pos
x
pos'))
(decreases FStar.UInt32.v pos' - FStar.UInt32.v pos) | {
"end_col": 5,
"end_line": 322,
"start_col": 2,
"start_line": 313
} |
FStar.Pervasives.Lemma | val valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires
(k.parser_kind_low > 0 /\ k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos))
(ensures
(let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos)) | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
k.parser_kind_low > 0 /\
k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos
))
(ensures (
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos
))
= if n = 0
then begin
valid_nlist_nil_recip p h sl pos;
valid_list_nil p h sl pos
end else begin
valid_nlist_cons_recip n p h sl pos;
let pos1 = get_valid_pos p h sl pos in
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_nlist_valid_list (n - 1) p h sl pos1;
valid_list_cons p h sl pos pos'
end | val valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires
(k.parser_kind_low > 0 /\ k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos))
(ensures
(let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos))
let rec valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires
(k.parser_kind_low > 0 /\ k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos))
(ensures
(let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos)) = | false | null | true | if n = 0
then
(valid_nlist_nil_recip p h sl pos;
valid_list_nil p h sl pos)
else
(valid_nlist_cons_recip n p h sl pos;
let pos1 = get_valid_pos p h sl pos in
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_nlist_valid_list (n - 1) p h sl pos1;
valid_list_cons p h sl pos pos') | {
"checked_file": "LowParse.Low.VCList.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
"lemma"
] | [
"Prims.nat",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"Prims.op_Equality",
"Prims.int",
"LowParse.Low.Base.Spec.valid_list_nil",
"Prims.unit",
"LowParse.Low.VCList.valid_nlist_nil_recip",
"Prims.bool",
"LowParse.Low.Base.Spec.valid_list_cons",
"LowParse.Low.VCList.valid_nlist_valid_list",
"Prims.op_Subtraction",
"LowParse.Low.Base.Spec.get_valid_pos",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"LowParse.Low.VCList.valid_nlist_cons_recip",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThan",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"LowParse.Low.Base.Spec.valid",
"Prims.squash",
"LowParse.Low.Base.Spec.valid_list",
"Prims.list",
"LowParse.Low.Base.Spec.contents_list",
"LowParse.Low.Base.Spec.contents",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
#push-options "--z3rlimit 32"
inline_for_extraction
let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 : B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U64.v pos <= U64.v pos1 /\ (
if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==> valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\ valid (parse_nlist (U32.v r) p) h0 input pos1) ==> get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~ (valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@inline_let]
let stop = is_error pos2 in
[@inline_let]
let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
if is_success res
then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res
inline_for_extraction
let jump_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U32.v pos <= U32.v pos1 /\
U32.v pos1 <= U32.v input.len /\
valid (parse_nlist (U32.v n) p) h0 input pos /\ valid (parse_nlist (U32.v r) p) h0 input pos1 /\
get_valid_pos (parse_nlist (U32.v n) p) h0 input pos == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1 /\
(stop == true ==> r == 0ul)
))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
[@inline_let]
let _ =
valid_nlist_cons_recip (U32.v r) p h0 input pos1
in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
false
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
valid_nlist_nil p h0 input res
in
HST.pop_frame ();
res
#pop-options
let rec valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
k.parser_kind_low > 0 /\
k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos
))
(ensures (
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos | false | false | LowParse.Low.VCList.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires
(k.parser_kind_low > 0 /\ k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos))
(ensures
(let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos)) | [
"recursion"
] | LowParse.Low.VCList.valid_nlist_valid_list | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
n: Prims.nat ->
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
sl: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(requires
Mkparser_kind'?.parser_kind_low k > 0 /\
Mkparser_kind'?.parser_kind_subkind k ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong /\
LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist n p) h sl pos)
(ensures
(let pos' =
LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.VCList.parse_nlist n p) h sl pos
in
LowParse.Low.Base.Spec.valid_list p h sl pos pos' /\
LowParse.Low.Base.Spec.contents_list p h sl pos pos' ==
LowParse.Low.Base.Spec.contents (LowParse.Spec.VCList.parse_nlist n p) h sl pos)) | {
"end_col": 5,
"end_line": 293,
"start_col": 2,
"start_line": 283
} |
FStar.Pervasives.Lemma | val valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ valid p h sl pos))
(ensures
(let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==>
get_valid_pos (parse_nlist n p) h sl pos ==
get_valid_pos (parse_nlist (n - 1) p) h sl pos1))) | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos | val valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ valid p h sl pos))
(ensures
(let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==>
get_valid_pos (parse_nlist n p) h sl pos ==
get_valid_pos (parse_nlist (n - 1) p) h sl pos1)))
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ valid p h sl pos))
(ensures
(let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==>
get_valid_pos (parse_nlist n p) h sl pos ==
get_valid_pos (parse_nlist (n - 1) p) h sl pos1))) = | false | null | true | Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos | {
"checked_file": "LowParse.Low.VCList.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
"lemma"
] | [
"Prims.nat",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"FStar.Classical.move_requires",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThan",
"LowParse.Low.Base.Spec.valid",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"Prims.op_Subtraction",
"LowParse.Low.Base.Spec.get_valid_pos",
"LowParse.Low.Base.Spec.valid_content_pos",
"Prims.Cons",
"LowParse.Low.Base.Spec.contents",
"LowParse.Low.VCList.valid_nlist_cons_recip",
"Prims.unit",
"Prims.op_Addition",
"LowParse.Low.VCList.valid_nlist_cons",
"Prims.squash",
"Prims.l_iff",
"Prims.l_imp",
"Prims.eq2",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1) | false | false | LowParse.Low.VCList.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ valid p h sl pos))
(ensures
(let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==>
get_valid_pos (parse_nlist n p) h sl pos ==
get_valid_pos (parse_nlist (n - 1) p) h sl pos1))) | [] | LowParse.Low.VCList.valid_nlist_cons' | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
n: Prims.nat ->
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
sl: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma (requires n > 0 /\ LowParse.Low.Base.Spec.valid p h sl pos)
(ensures
(let pos1 = LowParse.Low.Base.Spec.get_valid_pos p h sl pos in
(LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist n p) h sl pos <==>
LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist (n - 1) p) h sl pos1) /\
(LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist n p) h sl pos /\
LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist (n - 1) p) h sl pos1 ==>
LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.VCList.parse_nlist n p) h sl pos ==
LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.VCList.parse_nlist (n - 1) p)
h
sl
pos1))) | {
"end_col": 63,
"end_line": 129,
"start_col": 2,
"start_line": 128
} |
FStar.Pervasives.Lemma | val valid_vclist_elim
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#lk: parser_kind)
(lp: parser lk U32.t {lk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid (parse_vclist min max lp p) h input pos))
(ensures
(valid lp h input pos /\
(let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
let x = contents (parse_vclist min max lp p) h input pos in
L.length x == U32.v len /\
valid_content_pos (parse_nlist (U32.v len) p)
h
input
pos1
x
(get_valid_pos (parse_vclist min max lp p) h input pos)))) | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_vclist_elim
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#lk: parser_kind)
(lp: parser lk U32.t { lk.parser_kind_subkind == Some ParserStrong })
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_vclist min max lp p) h input pos))
(ensures (
valid lp h input pos /\ (
let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
let x = contents (parse_vclist min max lp p) h input pos in
L.length x == U32.v len /\
valid_content_pos (parse_nlist (U32.v len) p) h input pos1 x (get_valid_pos (parse_vclist min max lp p) h input pos)
)))
= valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos;
let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
valid_facts (parse_nlist (U32.v len) p) h input pos1 | val valid_vclist_elim
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#lk: parser_kind)
(lp: parser lk U32.t {lk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid (parse_vclist min max lp p) h input pos))
(ensures
(valid lp h input pos /\
(let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
let x = contents (parse_vclist min max lp p) h input pos in
L.length x == U32.v len /\
valid_content_pos (parse_nlist (U32.v len) p)
h
input
pos1
x
(get_valid_pos (parse_vclist min max lp p) h input pos))))
let valid_vclist_elim
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#lk: parser_kind)
(lp: parser lk U32.t {lk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid (parse_vclist min max lp p) h input pos))
(ensures
(valid lp h input pos /\
(let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
let x = contents (parse_vclist min max lp p) h input pos in
L.length x == U32.v len /\
valid_content_pos (parse_nlist (U32.v len) p)
h
input
pos1
x
(get_valid_pos (parse_vclist min max lp p) h input pos)))) = | false | null | true | valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos;
let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
valid_facts (parse_nlist (U32.v len) p) h input pos1 | {
"checked_file": "LowParse.Low.VCList.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.UInt32.t",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.VCList.parse_nlist_kind",
"FStar.UInt32.v",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"LowParse.Low.Base.Spec.get_valid_pos",
"LowParse.Low.Base.Spec.contents",
"Prims.unit",
"LowParse.Spec.VCList.parse_vclist_eq",
"LowParse.Slice.bytes_of_slice_from",
"LowParse.Spec.VCList.parse_vclist_kind",
"LowParse.Spec.Array.vlarray",
"LowParse.Spec.VCList.parse_vclist",
"LowParse.Low.Base.Spec.valid",
"Prims.squash",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt32.n",
"FStar.List.Tot.Base.length",
"LowParse.Low.Base.Spec.valid_content_pos",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
#push-options "--z3rlimit 32"
inline_for_extraction
let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 : B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U64.v pos <= U64.v pos1 /\ (
if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==> valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\ valid (parse_nlist (U32.v r) p) h0 input pos1) ==> get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~ (valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@inline_let]
let stop = is_error pos2 in
[@inline_let]
let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
if is_success res
then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res
inline_for_extraction
let jump_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U32.v pos <= U32.v pos1 /\
U32.v pos1 <= U32.v input.len /\
valid (parse_nlist (U32.v n) p) h0 input pos /\ valid (parse_nlist (U32.v r) p) h0 input pos1 /\
get_valid_pos (parse_nlist (U32.v n) p) h0 input pos == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1 /\
(stop == true ==> r == 0ul)
))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
[@inline_let]
let _ =
valid_nlist_cons_recip (U32.v r) p h0 input pos1
in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
false
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
valid_nlist_nil p h0 input res
in
HST.pop_frame ();
res
#pop-options
let rec valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
k.parser_kind_low > 0 /\
k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos
))
(ensures (
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos
))
= if n = 0
then begin
valid_nlist_nil_recip p h sl pos;
valid_list_nil p h sl pos
end else begin
valid_nlist_cons_recip n p h sl pos;
let pos1 = get_valid_pos p h sl pos in
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_nlist_valid_list (n - 1) p h sl pos1;
valid_list_cons p h sl pos pos'
end
let rec valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
(pos' : U32.t)
: Lemma
(requires (
valid_list p h sl pos pos'
))
(ensures (
let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'
))
(decreases (U32.v pos' - U32.v pos))
= if pos = pos'
then begin
valid_list_nil p h sl pos;
valid_nlist_nil p h sl pos
end else begin
valid_list_cons_recip p h sl pos pos' ;
let pos1 = get_valid_pos p h sl pos in
valid_list_valid_nlist p h sl pos1 pos' ;
valid_nlist_cons (L.length (contents_list p h sl pos1 pos')) p h sl pos
end
(* vclist *)
#push-options "--z3rlimit 16"
inline_for_extraction
let validate_vclist
(min: U32.t)
(max: U32.t { U32.v min <= U32.v max } )
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: validator lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_vclist (U32.v min) (U32.v max) lp p))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_vclist (U32.v min) (U32.v max) lp p) h input (uint64_to_uint32 pos);
parse_vclist_eq (U32.v min) (U32.v max) lp p (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts lp h input (uint64_to_uint32 pos)
in
let pos1 = lv input pos in
if is_error pos1
then pos1 // error
else
let n = lr input (uint64_to_uint32 pos) in
if n `U32.lt` min || max `U32.lt` n
then validator_error_generic
else
[@inline_let]
let _ = valid_facts (parse_nlist (U32.v n) p) h input (uint64_to_uint32 pos1) in
validate_nlist n v input pos1
inline_for_extraction
let jump_vclist
(min: nat)
(max: nat { min <= max } )
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: jumper lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_vclist min max lp p))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos
in
let pos1 = lv input pos in
let n = lr input pos in
[@inline_let]
let _ = valid_facts (parse_nlist (U32.v n) p) h input pos1 in
jump_nlist n v input pos1
#pop-options
let valid_vclist_elim
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#lk: parser_kind)
(lp: parser lk U32.t { lk.parser_kind_subkind == Some ParserStrong })
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_vclist min max lp p) h input pos))
(ensures (
valid lp h input pos /\ (
let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
let x = contents (parse_vclist min max lp p) h input pos in
L.length x == U32.v len /\
valid_content_pos (parse_nlist (U32.v len) p) h input pos1 x (get_valid_pos (parse_vclist min max lp p) h input pos) | false | false | LowParse.Low.VCList.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_vclist_elim
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#lk: parser_kind)
(lp: parser lk U32.t {lk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid (parse_vclist min max lp p) h input pos))
(ensures
(valid lp h input pos /\
(let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
let x = contents (parse_vclist min max lp p) h input pos in
L.length x == U32.v len /\
valid_content_pos (parse_nlist (U32.v len) p)
h
input
pos1
x
(get_valid_pos (parse_vclist min max lp p) h input pos)))) | [] | LowParse.Low.VCList.valid_vclist_elim | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
lp:
LowParse.Spec.Base.parser lk FStar.UInt32.t
{ Mkparser_kind'?.parser_kind_subkind lk ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } ->
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
input: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(requires
LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_vclist min max lp p) h input pos)
(ensures
LowParse.Low.Base.Spec.valid lp h input pos /\
(let len = LowParse.Low.Base.Spec.contents lp h input pos in
let pos1 = LowParse.Low.Base.Spec.get_valid_pos lp h input pos in
let x =
LowParse.Low.Base.Spec.contents (LowParse.Spec.VCList.parse_vclist min max lp p)
h
input
pos
in
FStar.List.Tot.Base.length x == FStar.UInt32.v len /\
LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.VCList.parse_nlist (FStar.UInt32.v
len)
p)
h
input
pos1
x
(LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.VCList.parse_vclist min max lp p)
h
input
pos))) | {
"end_col": 54,
"end_line": 415,
"start_col": 2,
"start_line": 410
} |
Prims.Tot | val jump_vclist
(min: nat)
(max: nat{min <= max})
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: jumper lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_vclist min max lp p)) | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let jump_vclist
(min: nat)
(max: nat { min <= max } )
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: jumper lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_vclist min max lp p))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos
in
let pos1 = lv input pos in
let n = lr input pos in
[@inline_let]
let _ = valid_facts (parse_nlist (U32.v n) p) h input pos1 in
jump_nlist n v input pos1 | val jump_vclist
(min: nat)
(max: nat{min <= max})
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: jumper lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_vclist min max lp p))
let jump_vclist
(min: nat)
(max: nat{min <= max})
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: jumper lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_vclist min max lp p)) = | false | null | false | fun #rrel #rel input pos ->
let h = HST.get () in
[@@ inline_let ]let _ =
valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos
in
let pos1 = lv input pos in
let n = lr input pos in
[@@ inline_let ]let _ = valid_facts (parse_nlist (U32.v n) p) h input pos1 in
jump_nlist n v input pos1 | {
"checked_file": "LowParse.Low.VCList.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.UInt32.t",
"LowParse.Low.Base.jumper",
"LowParse.Low.Base.leaf_reader",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"LowParse.Low.VCList.jump_nlist",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.VCList.parse_nlist_kind",
"FStar.UInt32.v",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"LowParse.Spec.VCList.parse_vclist_eq",
"LowParse.Slice.bytes_of_slice_from",
"LowParse.Spec.VCList.parse_vclist_kind",
"LowParse.Spec.Array.vlarray",
"LowParse.Spec.VCList.parse_vclist",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
#push-options "--z3rlimit 32"
inline_for_extraction
let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 : B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U64.v pos <= U64.v pos1 /\ (
if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==> valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\ valid (parse_nlist (U32.v r) p) h0 input pos1) ==> get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~ (valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@inline_let]
let stop = is_error pos2 in
[@inline_let]
let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
if is_success res
then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res
inline_for_extraction
let jump_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U32.v pos <= U32.v pos1 /\
U32.v pos1 <= U32.v input.len /\
valid (parse_nlist (U32.v n) p) h0 input pos /\ valid (parse_nlist (U32.v r) p) h0 input pos1 /\
get_valid_pos (parse_nlist (U32.v n) p) h0 input pos == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1 /\
(stop == true ==> r == 0ul)
))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
[@inline_let]
let _ =
valid_nlist_cons_recip (U32.v r) p h0 input pos1
in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
false
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
valid_nlist_nil p h0 input res
in
HST.pop_frame ();
res
#pop-options
let rec valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
k.parser_kind_low > 0 /\
k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos
))
(ensures (
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos
))
= if n = 0
then begin
valid_nlist_nil_recip p h sl pos;
valid_list_nil p h sl pos
end else begin
valid_nlist_cons_recip n p h sl pos;
let pos1 = get_valid_pos p h sl pos in
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_nlist_valid_list (n - 1) p h sl pos1;
valid_list_cons p h sl pos pos'
end
let rec valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
(pos' : U32.t)
: Lemma
(requires (
valid_list p h sl pos pos'
))
(ensures (
let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'
))
(decreases (U32.v pos' - U32.v pos))
= if pos = pos'
then begin
valid_list_nil p h sl pos;
valid_nlist_nil p h sl pos
end else begin
valid_list_cons_recip p h sl pos pos' ;
let pos1 = get_valid_pos p h sl pos in
valid_list_valid_nlist p h sl pos1 pos' ;
valid_nlist_cons (L.length (contents_list p h sl pos1 pos')) p h sl pos
end
(* vclist *)
#push-options "--z3rlimit 16"
inline_for_extraction
let validate_vclist
(min: U32.t)
(max: U32.t { U32.v min <= U32.v max } )
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: validator lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_vclist (U32.v min) (U32.v max) lp p))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_vclist (U32.v min) (U32.v max) lp p) h input (uint64_to_uint32 pos);
parse_vclist_eq (U32.v min) (U32.v max) lp p (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts lp h input (uint64_to_uint32 pos)
in
let pos1 = lv input pos in
if is_error pos1
then pos1 // error
else
let n = lr input (uint64_to_uint32 pos) in
if n `U32.lt` min || max `U32.lt` n
then validator_error_generic
else
[@inline_let]
let _ = valid_facts (parse_nlist (U32.v n) p) h input (uint64_to_uint32 pos1) in
validate_nlist n v input pos1
inline_for_extraction
let jump_vclist
(min: nat)
(max: nat { min <= max } )
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: jumper lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p) | false | false | LowParse.Low.VCList.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val jump_vclist
(min: nat)
(max: nat{min <= max})
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: jumper lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_vclist min max lp p)) | [] | LowParse.Low.VCList.jump_vclist | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
min: Prims.nat ->
max: Prims.nat{min <= max} ->
lv: LowParse.Low.Base.jumper lp ->
lr: LowParse.Low.Base.leaf_reader lp ->
v: LowParse.Low.Base.jumper p
-> LowParse.Low.Base.jumper (LowParse.Spec.VCList.parse_vclist min max lp p) | {
"end_col": 27,
"end_line": 384,
"start_col": 2,
"start_line": 373
} |
FStar.Pervasives.Lemma | val valid_vclist_intro
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#lk: parser_kind)
(lp: parser lk U32.t {lk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma
(requires
(valid lp h input pos /\
(let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
min <= U32.v len /\ U32.v len <= max /\ valid (parse_nlist (U32.v len) p) h input pos1))
)
(ensures
(let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
valid_content_pos (parse_vclist min max lp p)
h
input
pos
(contents (parse_nlist (U32.v len) p) h input pos1)
(get_valid_pos (parse_nlist (U32.v len) p) h input pos1))) | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_vclist_intro
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#lk: parser_kind)
(lp: parser lk U32.t { lk.parser_kind_subkind == Some ParserStrong })
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid lp h input pos /\ (
let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
min <= U32.v len /\ U32.v len <= max /\
valid (parse_nlist (U32.v len) p) h input pos1
)))
(ensures (
let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
valid_content_pos (parse_vclist min max lp p) h input pos (contents (parse_nlist (U32.v len) p) h input pos1) (get_valid_pos (parse_nlist (U32.v len) p) h input pos1)
))
= valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos;
let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
valid_facts (parse_nlist (U32.v len) p) h input pos1 | val valid_vclist_intro
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#lk: parser_kind)
(lp: parser lk U32.t {lk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma
(requires
(valid lp h input pos /\
(let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
min <= U32.v len /\ U32.v len <= max /\ valid (parse_nlist (U32.v len) p) h input pos1))
)
(ensures
(let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
valid_content_pos (parse_vclist min max lp p)
h
input
pos
(contents (parse_nlist (U32.v len) p) h input pos1)
(get_valid_pos (parse_nlist (U32.v len) p) h input pos1)))
let valid_vclist_intro
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#lk: parser_kind)
(lp: parser lk U32.t {lk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma
(requires
(valid lp h input pos /\
(let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
min <= U32.v len /\ U32.v len <= max /\ valid (parse_nlist (U32.v len) p) h input pos1))
)
(ensures
(let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
valid_content_pos (parse_vclist min max lp p)
h
input
pos
(contents (parse_nlist (U32.v len) p) h input pos1)
(get_valid_pos (parse_nlist (U32.v len) p) h input pos1))) = | false | null | true | valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos;
let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
valid_facts (parse_nlist (U32.v len) p) h input pos1 | {
"checked_file": "LowParse.Low.VCList.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.UInt32.t",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.VCList.parse_nlist_kind",
"FStar.UInt32.v",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"LowParse.Low.Base.Spec.get_valid_pos",
"LowParse.Low.Base.Spec.contents",
"Prims.unit",
"LowParse.Spec.VCList.parse_vclist_eq",
"LowParse.Slice.bytes_of_slice_from",
"LowParse.Spec.VCList.parse_vclist_kind",
"LowParse.Spec.Array.vlarray",
"LowParse.Spec.VCList.parse_vclist",
"LowParse.Low.Base.Spec.valid",
"Prims.squash",
"LowParse.Low.Base.Spec.valid_content_pos",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
#push-options "--z3rlimit 32"
inline_for_extraction
let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 : B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U64.v pos <= U64.v pos1 /\ (
if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==> valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\ valid (parse_nlist (U32.v r) p) h0 input pos1) ==> get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~ (valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@inline_let]
let stop = is_error pos2 in
[@inline_let]
let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
if is_success res
then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res
inline_for_extraction
let jump_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U32.v pos <= U32.v pos1 /\
U32.v pos1 <= U32.v input.len /\
valid (parse_nlist (U32.v n) p) h0 input pos /\ valid (parse_nlist (U32.v r) p) h0 input pos1 /\
get_valid_pos (parse_nlist (U32.v n) p) h0 input pos == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1 /\
(stop == true ==> r == 0ul)
))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
[@inline_let]
let _ =
valid_nlist_cons_recip (U32.v r) p h0 input pos1
in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
false
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
valid_nlist_nil p h0 input res
in
HST.pop_frame ();
res
#pop-options
let rec valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
k.parser_kind_low > 0 /\
k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos
))
(ensures (
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos
))
= if n = 0
then begin
valid_nlist_nil_recip p h sl pos;
valid_list_nil p h sl pos
end else begin
valid_nlist_cons_recip n p h sl pos;
let pos1 = get_valid_pos p h sl pos in
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_nlist_valid_list (n - 1) p h sl pos1;
valid_list_cons p h sl pos pos'
end
let rec valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
(pos' : U32.t)
: Lemma
(requires (
valid_list p h sl pos pos'
))
(ensures (
let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'
))
(decreases (U32.v pos' - U32.v pos))
= if pos = pos'
then begin
valid_list_nil p h sl pos;
valid_nlist_nil p h sl pos
end else begin
valid_list_cons_recip p h sl pos pos' ;
let pos1 = get_valid_pos p h sl pos in
valid_list_valid_nlist p h sl pos1 pos' ;
valid_nlist_cons (L.length (contents_list p h sl pos1 pos')) p h sl pos
end
(* vclist *)
#push-options "--z3rlimit 16"
inline_for_extraction
let validate_vclist
(min: U32.t)
(max: U32.t { U32.v min <= U32.v max } )
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: validator lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_vclist (U32.v min) (U32.v max) lp p))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_vclist (U32.v min) (U32.v max) lp p) h input (uint64_to_uint32 pos);
parse_vclist_eq (U32.v min) (U32.v max) lp p (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts lp h input (uint64_to_uint32 pos)
in
let pos1 = lv input pos in
if is_error pos1
then pos1 // error
else
let n = lr input (uint64_to_uint32 pos) in
if n `U32.lt` min || max `U32.lt` n
then validator_error_generic
else
[@inline_let]
let _ = valid_facts (parse_nlist (U32.v n) p) h input (uint64_to_uint32 pos1) in
validate_nlist n v input pos1
inline_for_extraction
let jump_vclist
(min: nat)
(max: nat { min <= max } )
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: jumper lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_vclist min max lp p))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos
in
let pos1 = lv input pos in
let n = lr input pos in
[@inline_let]
let _ = valid_facts (parse_nlist (U32.v n) p) h input pos1 in
jump_nlist n v input pos1
#pop-options
let valid_vclist_elim
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#lk: parser_kind)
(lp: parser lk U32.t { lk.parser_kind_subkind == Some ParserStrong })
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_vclist min max lp p) h input pos))
(ensures (
valid lp h input pos /\ (
let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
let x = contents (parse_vclist min max lp p) h input pos in
L.length x == U32.v len /\
valid_content_pos (parse_nlist (U32.v len) p) h input pos1 x (get_valid_pos (parse_vclist min max lp p) h input pos)
)))
= valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos;
let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
valid_facts (parse_nlist (U32.v len) p) h input pos1
#push-options "--z3rlimit 20"
let valid_vclist_intro
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#lk: parser_kind)
(lp: parser lk U32.t { lk.parser_kind_subkind == Some ParserStrong })
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid lp h input pos /\ (
let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
min <= U32.v len /\ U32.v len <= max /\
valid (parse_nlist (U32.v len) p) h input pos1
)))
(ensures (
let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
valid_content_pos (parse_vclist min max lp p) h input pos (contents (parse_nlist (U32.v len) p) h input pos1) (get_valid_pos (parse_nlist (U32.v len) p) h input pos1) | false | false | LowParse.Low.VCList.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_vclist_intro
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#lk: parser_kind)
(lp: parser lk U32.t {lk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma
(requires
(valid lp h input pos /\
(let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
min <= U32.v len /\ U32.v len <= max /\ valid (parse_nlist (U32.v len) p) h input pos1))
)
(ensures
(let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
valid_content_pos (parse_vclist min max lp p)
h
input
pos
(contents (parse_nlist (U32.v len) p) h input pos1)
(get_valid_pos (parse_nlist (U32.v len) p) h input pos1))) | [] | LowParse.Low.VCList.valid_vclist_intro | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
lp:
LowParse.Spec.Base.parser lk FStar.UInt32.t
{ Mkparser_kind'?.parser_kind_subkind lk ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } ->
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
input: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(requires
LowParse.Low.Base.Spec.valid lp h input pos /\
(let pos1 = LowParse.Low.Base.Spec.get_valid_pos lp h input pos in
let len = LowParse.Low.Base.Spec.contents lp h input pos in
min <= FStar.UInt32.v len /\ FStar.UInt32.v len <= max /\
LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist (FStar.UInt32.v len) p)
h
input
pos1))
(ensures
(let pos1 = LowParse.Low.Base.Spec.get_valid_pos lp h input pos in
let len = LowParse.Low.Base.Spec.contents lp h input pos in
LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.VCList.parse_vclist min max lp p)
h
input
pos
(LowParse.Low.Base.Spec.contents (LowParse.Spec.VCList.parse_nlist (FStar.UInt32.v len)
p)
h
input
pos1)
(LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.VCList.parse_nlist (FStar.UInt32.v len
)
p)
h
input
pos1))) | {
"end_col": 54,
"end_line": 448,
"start_col": 2,
"start_line": 443
} |
FStar.Pervasives.Lemma | val valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid p h sl pos /\ valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)))
(ensures
(valid p h sl pos /\ valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\
(let pos1 = get_valid_pos p h sl pos in
valid_content_pos (parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)))) | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos) | val valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid p h sl pos /\ valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)))
(ensures
(valid p h sl pos /\ valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\
(let pos1 = get_valid_pos p h sl pos in
valid_content_pos (parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1))))
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid p h sl pos /\ valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)))
(ensures
(valid p h sl pos /\ valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\
(let pos1 = get_valid_pos p h sl pos in
valid_content_pos (parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)))) = | false | null | true | let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos) | {
"checked_file": "LowParse.Low.VCList.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
"lemma"
] | [
"Prims.nat",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"LowParse.Spec.VCList.parse_nlist_eq",
"Prims.op_Addition",
"LowParse.Slice.bytes_of_slice_from",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"LowParse.Low.Base.Spec.get_valid_pos",
"Prims.l_and",
"LowParse.Low.Base.Spec.valid",
"Prims.squash",
"LowParse.Low.Base.Spec.valid_content_pos",
"Prims.Cons",
"LowParse.Low.Base.Spec.contents",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1) | false | false | LowParse.Low.VCList.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid p h sl pos /\ valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)))
(ensures
(valid p h sl pos /\ valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\
(let pos1 = get_valid_pos p h sl pos in
valid_content_pos (parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)))) | [] | LowParse.Low.VCList.valid_nlist_cons | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
n: Prims.nat ->
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
sl: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(requires
LowParse.Low.Base.Spec.valid p h sl pos /\
LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist n p)
h
sl
(LowParse.Low.Base.Spec.get_valid_pos p h sl pos))
(ensures
LowParse.Low.Base.Spec.valid p h sl pos /\
LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist n p)
h
sl
(LowParse.Low.Base.Spec.get_valid_pos p h sl pos) /\
(let pos1 = LowParse.Low.Base.Spec.get_valid_pos p h sl pos in
LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.VCList.parse_nlist (n + 1) p)
h
sl
pos
(LowParse.Low.Base.Spec.contents p h sl pos ::
LowParse.Low.Base.Spec.contents (LowParse.Spec.VCList.parse_nlist n p) h sl pos1)
(LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.VCList.parse_nlist n p) h sl pos1))
) | {
"end_col": 57,
"end_line": 73,
"start_col": 1,
"start_line": 69
} |
FStar.Pervasives.Lemma | val valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ valid (parse_nlist n p) h sl pos))
(ensures
(valid p h sl pos /\
(let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos (parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)))) | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1 | val valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ valid (parse_nlist n p) h sl pos))
(ensures
(valid p h sl pos /\
(let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos (parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1))))
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ valid (parse_nlist n p) h sl pos))
(ensures
(valid p h sl pos /\
(let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos (parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)))) = | false | null | true | valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1 | {
"checked_file": "LowParse.Low.VCList.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
"lemma"
] | [
"Prims.nat",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.VCList.parse_nlist_kind",
"Prims.op_Subtraction",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"LowParse.Low.Base.Spec.get_valid_pos",
"Prims.unit",
"LowParse.Spec.VCList.parse_nlist_eq",
"LowParse.Slice.bytes_of_slice_from",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThan",
"LowParse.Low.Base.Spec.valid",
"Prims.squash",
"LowParse.Low.Base.Spec.valid_content_pos",
"Prims.Cons",
"LowParse.Low.Base.Spec.contents",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1) | false | false | LowParse.Low.VCList.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ valid (parse_nlist n p) h sl pos))
(ensures
(valid p h sl pos /\
(let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos (parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)))) | [] | LowParse.Low.VCList.valid_nlist_cons_recip | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
n: Prims.nat ->
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
sl: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(requires
n > 0 /\ LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist n p) h sl pos)
(ensures
LowParse.Low.Base.Spec.valid p h sl pos /\
(let pos1 = LowParse.Low.Base.Spec.get_valid_pos p h sl pos in
LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist (n - 1) p)
h
sl
(LowParse.Low.Base.Spec.get_valid_pos p h sl pos) /\
LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.VCList.parse_nlist n p)
h
sl
pos
(LowParse.Low.Base.Spec.contents p h sl pos ::
LowParse.Low.Base.Spec.contents (LowParse.Spec.VCList.parse_nlist (n - 1) p) h sl pos1
)
(LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.VCList.parse_nlist (n - 1) p)
h
sl
pos1))) | {
"end_col": 47,
"end_line": 105,
"start_col": 2,
"start_line": 101
} |
Prims.Tot | val validate_vclist
(min: U32.t)
(max: U32.t{U32.v min <= U32.v max})
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: validator lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_vclist (U32.v min) (U32.v max) lp p)) | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let validate_vclist
(min: U32.t)
(max: U32.t { U32.v min <= U32.v max } )
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: validator lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_vclist (U32.v min) (U32.v max) lp p))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_vclist (U32.v min) (U32.v max) lp p) h input (uint64_to_uint32 pos);
parse_vclist_eq (U32.v min) (U32.v max) lp p (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts lp h input (uint64_to_uint32 pos)
in
let pos1 = lv input pos in
if is_error pos1
then pos1 // error
else
let n = lr input (uint64_to_uint32 pos) in
if n `U32.lt` min || max `U32.lt` n
then validator_error_generic
else
[@inline_let]
let _ = valid_facts (parse_nlist (U32.v n) p) h input (uint64_to_uint32 pos1) in
validate_nlist n v input pos1 | val validate_vclist
(min: U32.t)
(max: U32.t{U32.v min <= U32.v max})
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: validator lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_vclist (U32.v min) (U32.v max) lp p))
let validate_vclist
(min: U32.t)
(max: U32.t{U32.v min <= U32.v max})
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: validator lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_vclist (U32.v min) (U32.v max) lp p)) = | false | null | false | fun #rrel #rel input pos ->
let h = HST.get () in
[@@ inline_let ]let _ =
valid_facts (parse_vclist (U32.v min) (U32.v max) lp p) h input (uint64_to_uint32 pos);
parse_vclist_eq (U32.v min)
(U32.v max)
lp
p
(bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts lp h input (uint64_to_uint32 pos)
in
let pos1 = lv input pos in
if is_error pos1
then pos1
else
let n = lr input (uint64_to_uint32 pos) in
if n `U32.lt` min || max `U32.lt` n
then validator_error_generic
else
[@@ inline_let ]let _ =
valid_facts (parse_nlist (U32.v n) p) h input (uint64_to_uint32 pos1)
in
validate_nlist n v input pos1 | {
"checked_file": "LowParse.Low.VCList.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Low.Base.validator",
"LowParse.Low.Base.leaf_reader",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt64.t",
"LowParse.Low.ErrorCode.is_error",
"Prims.bool",
"Prims.op_BarBar",
"FStar.UInt32.lt",
"LowParse.Low.ErrorCode.validator_error_generic",
"LowParse.Low.VCList.validate_nlist",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"LowParse.Low.ErrorCode.uint64_to_uint32",
"LowParse.Spec.VCList.parse_vclist_eq",
"LowParse.Slice.bytes_of_slice_from",
"LowParse.Spec.VCList.parse_vclist_kind",
"LowParse.Spec.Array.vlarray",
"LowParse.Spec.VCList.parse_vclist",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
#push-options "--z3rlimit 32"
inline_for_extraction
let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 : B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U64.v pos <= U64.v pos1 /\ (
if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==> valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\ valid (parse_nlist (U32.v r) p) h0 input pos1) ==> get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~ (valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@inline_let]
let stop = is_error pos2 in
[@inline_let]
let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
if is_success res
then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res
inline_for_extraction
let jump_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U32.v pos <= U32.v pos1 /\
U32.v pos1 <= U32.v input.len /\
valid (parse_nlist (U32.v n) p) h0 input pos /\ valid (parse_nlist (U32.v r) p) h0 input pos1 /\
get_valid_pos (parse_nlist (U32.v n) p) h0 input pos == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1 /\
(stop == true ==> r == 0ul)
))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
[@inline_let]
let _ =
valid_nlist_cons_recip (U32.v r) p h0 input pos1
in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
false
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
valid_nlist_nil p h0 input res
in
HST.pop_frame ();
res
#pop-options
let rec valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
k.parser_kind_low > 0 /\
k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos
))
(ensures (
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos
))
= if n = 0
then begin
valid_nlist_nil_recip p h sl pos;
valid_list_nil p h sl pos
end else begin
valid_nlist_cons_recip n p h sl pos;
let pos1 = get_valid_pos p h sl pos in
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_nlist_valid_list (n - 1) p h sl pos1;
valid_list_cons p h sl pos pos'
end
let rec valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
(pos' : U32.t)
: Lemma
(requires (
valid_list p h sl pos pos'
))
(ensures (
let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'
))
(decreases (U32.v pos' - U32.v pos))
= if pos = pos'
then begin
valid_list_nil p h sl pos;
valid_nlist_nil p h sl pos
end else begin
valid_list_cons_recip p h sl pos pos' ;
let pos1 = get_valid_pos p h sl pos in
valid_list_valid_nlist p h sl pos1 pos' ;
valid_nlist_cons (L.length (contents_list p h sl pos1 pos')) p h sl pos
end
(* vclist *)
#push-options "--z3rlimit 16"
inline_for_extraction
let validate_vclist
(min: U32.t)
(max: U32.t { U32.v min <= U32.v max } )
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: validator lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p) | false | false | LowParse.Low.VCList.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val validate_vclist
(min: U32.t)
(max: U32.t{U32.v min <= U32.v max})
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: validator lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_vclist (U32.v min) (U32.v max) lp p)) | [] | LowParse.Low.VCList.validate_vclist | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
min: FStar.UInt32.t ->
max: FStar.UInt32.t{FStar.UInt32.v min <= FStar.UInt32.v max} ->
lv: LowParse.Low.Base.validator lp ->
lr: LowParse.Low.Base.leaf_reader lp ->
v: LowParse.Low.Base.validator p
-> LowParse.Low.Base.validator (LowParse.Spec.VCList.parse_vclist (FStar.UInt32.v min)
(FStar.UInt32.v max)
lp
p) | {
"end_col": 35,
"end_line": 358,
"start_col": 2,
"start_line": 341
} |
Prims.Tot | val jump_nlist (n: U32.t) (#k: parser_kind) (#t: Type) (#p: parser k t) (v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p)) | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let jump_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U32.v pos <= U32.v pos1 /\
U32.v pos1 <= U32.v input.len /\
valid (parse_nlist (U32.v n) p) h0 input pos /\ valid (parse_nlist (U32.v r) p) h0 input pos1 /\
get_valid_pos (parse_nlist (U32.v n) p) h0 input pos == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1 /\
(stop == true ==> r == 0ul)
))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
[@inline_let]
let _ =
valid_nlist_cons_recip (U32.v r) p h0 input pos1
in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
false
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
valid_nlist_nil p h0 input res
in
HST.pop_frame ();
res | val jump_nlist (n: U32.t) (#k: parser_kind) (#t: Type) (#p: parser k t) (v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p))
let jump_nlist (n: U32.t) (#k: parser_kind) (#t: Type) (#p: parser k t) (v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p)) = | false | null | false | fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while (fun h stop ->
B.modifies ((B.loc_buffer bpos1) `B.loc_union` (B.loc_buffer br)) h1 h /\
(let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\ U32.v pos <= U32.v pos1 /\ U32.v pos1 <= U32.v input.len /\
valid (parse_nlist (U32.v n) p) h0 input pos /\
valid (parse_nlist (U32.v r) p) h0 input pos1 /\
get_valid_pos (parse_nlist (U32.v n) p) h0 input pos ==
get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1 /\ (stop == true ==> r == 0ul)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
[@@ inline_let ]let _ = valid_nlist_cons_recip (U32.v r) p h0 input pos1 in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
false);
let res = B.index bpos1 0ul in
[@@ inline_let ]let _ = valid_nlist_nil p h0 input res in
HST.pop_frame ();
res | {
"checked_file": "LowParse.Low.VCList.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
"total"
] | [
"FStar.UInt32.t",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Low.Base.jumper",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"LowParse.Low.VCList.valid_nlist_nil",
"LowStar.Monotonic.Buffer.index",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.__uint_to_t",
"C.Loops.do_while",
"FStar.Monotonic.HyperStack.mem",
"Prims.bool",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_union",
"LowStar.Monotonic.Buffer.loc_buffer",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"LowParse.Slice.__proj__Mkslice__item__len",
"LowParse.Low.Base.Spec.valid",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"Prims.eq2",
"LowParse.Low.Base.Spec.get_valid_pos",
"Prims.l_imp",
"LowStar.Monotonic.Buffer.get",
"Prims.op_Equality",
"LowStar.Monotonic.Buffer.upd",
"FStar.UInt32.sub",
"LowParse.Low.VCList.valid_nlist_cons_recip",
"FStar.HyperStack.ST.get",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.uint_to_t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Buffer.alloca",
"FStar.HyperStack.ST.push_frame"
] | [] | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
#push-options "--z3rlimit 32"
inline_for_extraction
let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 : B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U64.v pos <= U64.v pos1 /\ (
if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==> valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\ valid (parse_nlist (U32.v r) p) h0 input pos1) ==> get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~ (valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@inline_let]
let stop = is_error pos2 in
[@inline_let]
let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
if is_success res
then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res
inline_for_extraction
let jump_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p) | false | false | LowParse.Low.VCList.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 32,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val jump_nlist (n: U32.t) (#k: parser_kind) (#t: Type) (#p: parser k t) (v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p)) | [] | LowParse.Low.VCList.jump_nlist | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | n: FStar.UInt32.t -> v: LowParse.Low.Base.jumper p
-> LowParse.Low.Base.jumper (LowParse.Spec.VCList.parse_nlist (FStar.UInt32.v n) p) | {
"end_col": 5,
"end_line": 259,
"start_col": 2,
"start_line": 220
} |
Prims.Tot | val validate_nlist (n: U32.t) (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p)
: Tot (validator (parse_nlist (U32.v n) p)) | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 : B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U64.v pos <= U64.v pos1 /\ (
if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==> valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\ valid (parse_nlist (U32.v r) p) h0 input pos1) ==> get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~ (valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@inline_let]
let stop = is_error pos2 in
[@inline_let]
let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
if is_success res
then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res | val validate_nlist (n: U32.t) (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
let validate_nlist (n: U32.t) (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p)
: Tot (validator (parse_nlist (U32.v n) p)) = | false | null | false | fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1:B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while (fun h stop ->
B.modifies ((B.loc_buffer bpos1) `B.loc_union` (B.loc_buffer br)) h1 h /\
(let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\ U64.v pos <= U64.v pos1 /\
(if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==>
valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\
valid (parse_nlist (U32.v r) p) h0 input pos1) ==>
get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) ==
get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@@ inline_let ]let stop = is_error pos2 in
[@@ inline_let ]let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop);
let res = B.index bpos1 0ul in
[@@ inline_let ]let _ =
if is_success res then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res | {
"checked_file": "LowParse.Low.VCList.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
"total"
] | [
"FStar.UInt32.t",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Low.Base.validator",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt64.t",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"LowParse.Low.ErrorCode.is_success",
"LowParse.Low.VCList.valid_nlist_nil",
"LowParse.Low.ErrorCode.uint64_to_uint32",
"Prims.bool",
"LowStar.Monotonic.Buffer.index",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.__uint_to_t",
"C.Loops.do_while",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_union",
"LowStar.Monotonic.Buffer.loc_buffer",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"FStar.UInt64.v",
"LowParse.Slice.__proj__Mkslice__item__len",
"Prims.l_iff",
"LowParse.Low.Base.Spec.valid",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"Prims.l_imp",
"Prims.eq2",
"LowParse.Low.Base.Spec.get_valid_pos",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"Prims.l_not",
"Prims.logical",
"LowStar.Monotonic.Buffer.get",
"Prims.op_Equality",
"LowParse.Low.VCList.valid_nlist_cons_not",
"LowParse.Low.VCList.valid_nlist_cons'",
"LowParse.Low.ErrorCode.is_error",
"LowStar.Monotonic.Buffer.upd",
"FStar.UInt32.sub",
"FStar.HyperStack.ST.get",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.uint_to_t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Buffer.alloca",
"LowStar.Buffer.buffer",
"FStar.HyperStack.ST.push_frame"
] | [] | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
#push-options "--z3rlimit 32"
inline_for_extraction
let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p) | false | false | LowParse.Low.VCList.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 32,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val validate_nlist (n: U32.t) (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p)
: Tot (validator (parse_nlist (U32.v n) p)) | [] | LowParse.Low.VCList.validate_nlist | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | n: FStar.UInt32.t -> v: LowParse.Low.Base.validator p
-> LowParse.Low.Base.validator (LowParse.Spec.VCList.parse_nlist (FStar.UInt32.v n) p) | {
"end_col": 5,
"end_line": 210,
"start_col": 2,
"start_line": 161
} |
Prims.Pure | val list_to_seq_post (#a: Type) (l: list a) (s: seq a) (n: nat)
: Pure prop (requires n + List.length l == Seq.length s) (ensures fun _ -> True) (decreases l) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec list_to_seq_post (#a:Type) (l:list a) (s:seq a) (n:nat) : Pure prop
(requires n + List.length l == Seq.length s)
(ensures fun _ -> True)
(decreases l)
=
match l with
| [] -> n == Seq.length s
| h::t -> Seq.index s n == h /\ list_to_seq_post t s (n + 1) | val list_to_seq_post (#a: Type) (l: list a) (s: seq a) (n: nat)
: Pure prop (requires n + List.length l == Seq.length s) (ensures fun _ -> True) (decreases l)
let rec list_to_seq_post (#a: Type) (l: list a) (s: seq a) (n: nat)
: Pure prop (requires n + List.length l == Seq.length s) (ensures fun _ -> True) (decreases l) = | false | null | false | match l with
| [] -> n == Seq.length s
| h :: t -> Seq.index s n == h /\ list_to_seq_post t s (n + 1) | {
"checked_file": "Vale.Lib.Seqs.fsti.checked",
"dependencies": [
"Vale.Lib.Seqs_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Lib.Seqs.fsti"
} | [
""
] | [
"Prims.list",
"FStar.Seq.Base.seq",
"Prims.nat",
"Prims.eq2",
"FStar.Seq.Base.length",
"Prims.l_and",
"FStar.Seq.Base.index",
"Vale.Lib.Seqs.list_to_seq_post",
"Prims.op_Addition",
"Prims.prop",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.l_True"
] | [] | module Vale.Lib.Seqs
open FStar.Mul
open Vale.Lib.Seqs_s
open FStar.Seq
val lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) :
Lemma (slice (append x y) 0 (length x) == x)
val lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) :
Lemma (all_but_last (append a b) == append a (all_but_last b))
val reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) :
Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s))
val reverse_reverse_seq (#a:Type) (s:seq a) :
Lemma(ensures reverse_seq (reverse_seq s) == s)
[SMTPat (reverse_seq (reverse_seq s))]
val seq_map_i_indexed (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) :
Tot (s':seq b { length s' == length s /\
(forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j))
})
val seq_map_i (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) :
Tot (s':seq b { length s' == length s /\
(forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f j (index s j))
})
val seq_map_internal_associative (#a:Type) (#b:eqtype) (f:int->a->b) (s:seq a) (pivot:int{0 <= pivot /\ pivot < length s}) :
Lemma (let left,right = split s pivot in
seq_map_i f s == seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot )
val seq_map_inverses (#a #b:Type) (f:a -> b) (g:b -> a) (s:seq a) : Lemma
(requires forall x . g (f x) == x)
(ensures seq_map g (seq_map f s) == s)
val slice_append_adds (#a:Type) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) :
Lemma (slice s 0 i @| slice s i j == slice s 0 j)
val slice_seq_map_commute (#a #b:Type) (f:a -> b) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) :
Lemma (slice (seq_map f s) i j == seq_map f (slice s i j))
val append_distributes_seq_map (#a #b:Type) (f:a -> b) (s1 s2:seq a) :
Lemma (seq_map f (s1 @| s2) == seq_map f s1 @| seq_map f s2)
val seq_map_injective (#a #b:Type) (f:a -> b) (s s':seq a) : Lemma
(requires (forall (x x':a).{:pattern (f x); (f x')} f x == f x' ==> x == x') /\ seq_map f s == seq_map f s')
(ensures s == s')
val list_to_seq (#a:Type) (l:list a) : Pure (seq a)
(requires True)
(ensures fun s -> Seq.length s == List.length l)
let rec list_to_seq_post (#a:Type) (l:list a) (s:seq a) (n:nat) : Pure prop
(requires n + List.length l == Seq.length s)
(ensures fun _ -> True)
(decreases l) | false | false | Vale.Lib.Seqs.fsti | {
"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"
} | null | val list_to_seq_post (#a: Type) (l: list a) (s: seq a) (n: nat)
: Pure prop (requires n + List.length l == Seq.length s) (ensures fun _ -> True) (decreases l) | [
"recursion"
] | Vale.Lib.Seqs.list_to_seq_post | {
"file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | l: Prims.list a -> s: FStar.Seq.Base.seq a -> n: Prims.nat -> Prims.Pure Prims.prop | {
"end_col": 62,
"end_line": 63,
"start_col": 2,
"start_line": 61
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let meta_len (t:limb_t) = len:size_t{0 < v len /\ 2 * bits t * v len <= max_size_t} | let meta_len (t: limb_t) = | false | null | false | len: size_t{0 < v len /\ (2 * bits t) * v len <= max_size_t} | {
"checked_file": "Hacl.Bignum.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.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.Bignum.fsti"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.bits",
"Lib.IntTypes.max_size_t"
] | [] | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract
let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_add_mod_n_st t len
inline_for_extraction noextract
let bn_sub_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_sub_mod_n_st t len
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
b:lbignum t len
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_mul_st t len a
inline_for_extraction noextract
let bn_mul_st (t:limb_t) (aLen:size_t) (bLen:size_t{v aLen + v bLen <= max_size_t}) (a:lbignum t aLen) =
b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_mul:
#t:limb_t
-> aLen:size_t
-> bLen:size_t{v aLen + v bLen <= max_size_t}
-> a:lbignum t aLen ->
bn_mul_st t aLen bLen a
inline_for_extraction noextract
let bn_karatsuba_sqr_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a))
inline_for_extraction noextract
val bn_karatsuba_sqr:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_sqr_st t len a
inline_for_extraction noextract
let bn_sqr_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a))
inline_for_extraction noextract
val bn_sqr:
#t:limb_t
-> len:size_t{0 < v len /\ v len + v len <= max_size_t}
-> a:lbignum t len ->
bn_sqr_st t len a
inline_for_extraction noextract
val bn_mul1_lshift_add_in_place:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> b:limb t
-> resLen:size_t
-> j:size_t{v j + v aLen <= v resLen}
-> res:lbignum t resLen ->
Stack (limb t)
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b (v j) (as_seq h0 res))
inline_for_extraction noextract
val bn_rshift:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i < v len}
-> res:lbignum t (len -! i) ->
Stack unit
(requires fun h -> live h b /\ live h res /\ disjoint res b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_rshift (as_seq h0 b) (v i))
inline_for_extraction noextract
val bn_sub_mask:
#t:limb_t
-> len:size_t{v len > 0}
-> n:lbignum t len
-> a:lbignum t len ->
Stack unit
(requires fun h -> live h n /\ live h a /\ disjoint n a)
(ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_sub_mask (as_seq h0 n) (as_seq h0 a))
///
/// Get and set i-th bit of a bignum
///
inline_for_extraction noextract
val bn_get_ith_bit:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i / bits t < v len} ->
Stack (limb t)
(requires fun h -> live h b)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.bn_get_ith_bit (as_seq h0 b) (v i))
inline_for_extraction noextract
val bn_get_bits:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t
-> l:size_t{v l < bits t /\ v i / bits t < v len} ->
Stack (limb t)
(requires fun h -> live h b)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.bn_get_bits (as_seq h0 b) (v i) (v l))
inline_for_extraction noextract
val bn_set_ith_bit:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i / bits t < v len} ->
Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
as_seq h1 b == S.bn_set_ith_bit (as_seq h0 b) (v i))
inline_for_extraction noextract
val cswap2:
#t:limb_t
-> len:size_t
-> bit:limb t
-> b1:lbignum t len
-> b2:lbignum t len ->
Stack unit
(requires fun h -> live h b1 /\ live h b2 /\ disjoint b1 b2)
(ensures fun h0 _ h1 -> modifies (loc b1 |+| loc b2) h0 h1 /\
(as_seq h1 b1, as_seq h1 b2) == S.cswap2 bit (as_seq h0 b1) (as_seq h0 b2))
/// Start of the len-based specialization infrastructure.
///
/// Essentially, we wish to describe a type class of basic bignum operations
/// needed to implement Montgomery reduction. This will allow us to generate
/// specialized versions of modular exponentiation for a given bignum size.
///
/// This is done "by hand" because the specialization pattern is more
/// complicated than other pieces of code (chacha, poly, curve), meaning I don't
/// (yet) know how to automate it with a tactic. So, a type class seems like the
/// most efficient way to go about it.
///
/// The operations of the type class were found by essentially reading the code,
/// writing down which operations from Hacl.Bignum are (transitively) needed to
/// implement modular exponentiation, and figuring out for each call-site
/// whether they can be specialized for the bignum size, or whether they have to
/// been inline-for-extraction'd. | false | true | Hacl.Bignum.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val meta_len : t: Hacl.Bignum.Definitions.limb_t -> Type0 | [] | Hacl.Bignum.meta_len | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Hacl.Bignum.Definitions.limb_t -> Type0 | {
"end_col": 83,
"end_line": 373,
"start_col": 26,
"start_line": 373
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b)) | let bn_add_st (t: limb_t) = | false | null | false |
aLen: size_t ->
a: lbignum t aLen ->
bLen: size_t{v bLen <= v aLen} ->
b: lbignum t bLen ->
res: lbignum t aLen
-> Stack (carry t)
(requires
fun h ->
live h a /\ live h b /\ live h res /\ disjoint a b /\ eq_or_disjoint a res /\
disjoint b res)
(ensures
fun h0 c_out h1 ->
modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b)
) | {
"checked_file": "Hacl.Bignum.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.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.Bignum.fsti"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Spec.Bignum.Base.carry",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.Definitions.lbignum",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_add"
] | [] | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract | false | true | Hacl.Bignum.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_add_st : t: Hacl.Bignum.Definitions.limb_t -> Type0 | [] | Hacl.Bignum.bn_add_st | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Hacl.Bignum.Definitions.limb_t -> Type0 | {
"end_col": 67,
"end_line": 96,
"start_col": 4,
"start_line": 86
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b)) | let bn_sub_st (t: limb_t) = | false | null | false |
aLen: size_t ->
a: lbignum t aLen ->
bLen: size_t{v bLen <= v aLen} ->
b: lbignum t bLen ->
res: lbignum t aLen
-> Stack (carry t)
(requires
fun h ->
live h a /\ live h b /\ live h res /\ disjoint a b /\ eq_or_disjoint a res /\
disjoint b res)
(ensures
fun h0 c_out h1 ->
modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b)
) | {
"checked_file": "Hacl.Bignum.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.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.Bignum.fsti"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Spec.Bignum.Base.carry",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.Definitions.lbignum",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_sub"
] | [] | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract | false | true | Hacl.Bignum.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_sub_st : t: Hacl.Bignum.Definitions.limb_t -> Type0 | [] | Hacl.Bignum.bn_sub_st | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Hacl.Bignum.Definitions.limb_t -> Type0 | {
"end_col": 66,
"end_line": 115,
"start_col": 4,
"start_line": 105
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b)) | let bn_add_eq_len_st (t: limb_t) (len: size_t) = | false | null | false | a: lbignum t len -> b: lbignum t len -> res: lbignum t len
-> Stack (carry t)
(requires
fun h ->
live h a /\ live h b /\ live h res /\ eq_or_disjoint a b /\ eq_or_disjoint a res /\
eq_or_disjoint b res)
(ensures
fun h0 c_out h1 ->
modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b)
) | {
"checked_file": "Hacl.Bignum.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.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.Bignum.fsti"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Base.carry",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_add"
] | [] | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract | false | true | Hacl.Bignum.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_add_eq_len_st : t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0 | [] | Hacl.Bignum.bn_add_eq_len_st | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0 | {
"end_col": 67,
"end_line": 60,
"start_col": 5,
"start_line": 52
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b)) | let bn_add_mod_n_st (t: limb_t) (len: size_t{v len > 0}) = | false | null | false | n: lbignum t len -> a: lbignum t len -> b: lbignum t len -> res: lbignum t len
-> Stack unit
(requires
fun h ->
live h n /\ live h a /\ live h b /\ live h res /\ disjoint n a /\ disjoint n b /\
disjoint n res /\ eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures
fun h0 _ h1 ->
modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b)) | {
"checked_file": "Hacl.Bignum.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.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.Bignum.fsti"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Bignum.Definitions.lbignum",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_add_mod_n"
] | [] | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract | false | false | Hacl.Bignum.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_add_mod_n_st : t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> Type0 | [] | Hacl.Bignum.bn_add_mod_n_st | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> Type0 | {
"end_col": 78,
"end_line": 147,
"start_col": 4,
"start_line": 137
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_karatsuba_mul_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
b:lbignum t len
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) | let bn_karatsuba_mul_st
(t: limb_t)
(len: size_t{0 < v len /\ 4 * v len <= max_size_t})
(a: lbignum t len)
= | false | null | false | b: lbignum t len -> res: lbignum t (len +! len)
-> Stack unit
(requires
fun h ->
live h a /\ live h b /\ live h res /\ disjoint res a /\ disjoint res b /\
eq_or_disjoint a b)
(ensures
fun h0 _ h1 ->
modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) | {
"checked_file": "Hacl.Bignum.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.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.Bignum.fsti"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Spec.Bignum.Definitions.limb",
"Prims.op_Addition",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_mul"
] | [] | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract
let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_add_mod_n_st t len
inline_for_extraction noextract
let bn_sub_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_sub_mod_n_st t len
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
inline_for_extraction noextract | false | false | Hacl.Bignum.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_mul_st : t: Hacl.Bignum.Definitions.limb_t ->
len:
Lib.IntTypes.size_t
{0 < Lib.IntTypes.v len /\ 4 * Lib.IntTypes.v len <= Lib.IntTypes.max_size_t} ->
a: Hacl.Bignum.Definitions.lbignum t len
-> Type0 | [] | Hacl.Bignum.bn_karatsuba_mul_st | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Hacl.Bignum.Definitions.limb_t ->
len:
Lib.IntTypes.size_t
{0 < Lib.IntTypes.v len /\ 4 * Lib.IntTypes.v len <= Lib.IntTypes.max_size_t} ->
a: Hacl.Bignum.Definitions.lbignum t len
-> Type0 | {
"end_col": 58,
"end_line": 196,
"start_col": 4,
"start_line": 189
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b)) | let bn_sub_eq_len_st (t: limb_t) (len: size_t) = | false | null | false | a: lbignum t len -> b: lbignum t len -> res: lbignum t len
-> Stack (carry t)
(requires
fun h ->
live h a /\ live h b /\ live h res /\ eq_or_disjoint a b /\ eq_or_disjoint a res /\
eq_or_disjoint b res)
(ensures
fun h0 c_out h1 ->
modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b)
) | {
"checked_file": "Hacl.Bignum.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.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.Bignum.fsti"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Base.carry",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_sub"
] | [] | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract | false | true | Hacl.Bignum.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_sub_eq_len_st : t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0 | [] | Hacl.Bignum.bn_sub_eq_len_st | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0 | {
"end_col": 66,
"end_line": 77,
"start_col": 5,
"start_line": 69
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_sub_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b)) | let bn_sub_mod_n_st (t: limb_t) (len: size_t{v len > 0}) = | false | null | false | n: lbignum t len -> a: lbignum t len -> b: lbignum t len -> res: lbignum t len
-> Stack unit
(requires
fun h ->
live h n /\ live h a /\ live h b /\ live h res /\ disjoint n a /\ disjoint n b /\
disjoint n res /\ eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures
fun h0 _ h1 ->
modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b)) | {
"checked_file": "Hacl.Bignum.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.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.Bignum.fsti"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Bignum.Definitions.lbignum",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_sub_mod_n"
] | [] | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract
let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_add_mod_n_st t len
inline_for_extraction noextract | false | false | Hacl.Bignum.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_sub_mod_n_st : t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> Type0 | [] | Hacl.Bignum.bn_sub_mod_n_st | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> Type0 | {
"end_col": 78,
"end_line": 166,
"start_col": 4,
"start_line": 156
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_mul_st (t:limb_t) (aLen:size_t) (bLen:size_t{v aLen + v bLen <= max_size_t}) (a:lbignum t aLen) =
b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) | let bn_mul_st
(t: limb_t)
(aLen: size_t)
(bLen: size_t{v aLen + v bLen <= max_size_t})
(a: lbignum t aLen)
= | false | null | false | b: lbignum t bLen -> res: lbignum t (aLen +! bLen)
-> Stack unit
(requires
fun h ->
live h a /\ live h b /\ live h res /\ disjoint res a /\ disjoint res b /\
eq_or_disjoint a b)
(ensures
fun h0 _ h1 ->
modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) | {
"checked_file": "Hacl.Bignum.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.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.Bignum.fsti"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Spec.Bignum.Definitions.limb",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_mul"
] | [] | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract
let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_add_mod_n_st t len
inline_for_extraction noextract
let bn_sub_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_sub_mod_n_st t len
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
b:lbignum t len
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_mul_st t len a
inline_for_extraction noextract | false | false | Hacl.Bignum.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_mul_st : t: Hacl.Bignum.Definitions.limb_t ->
aLen: Lib.IntTypes.size_t ->
bLen: Lib.IntTypes.size_t{Lib.IntTypes.v aLen + Lib.IntTypes.v bLen <= Lib.IntTypes.max_size_t} ->
a: Hacl.Bignum.Definitions.lbignum t aLen
-> Type0 | [] | Hacl.Bignum.bn_mul_st | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Hacl.Bignum.Definitions.limb_t ->
aLen: Lib.IntTypes.size_t ->
bLen: Lib.IntTypes.size_t{Lib.IntTypes.v aLen + Lib.IntTypes.v bLen <= Lib.IntTypes.max_size_t} ->
a: Hacl.Bignum.Definitions.lbignum t aLen
-> Type0 | {
"end_col": 58,
"end_line": 216,
"start_col": 4,
"start_line": 209
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_karatsuba_sqr_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a)) | let bn_karatsuba_sqr_st
(t: limb_t)
(len: size_t{0 < v len /\ 4 * v len <= max_size_t})
(a: lbignum t len)
= | false | null | false | res: lbignum t (len +! len)
-> Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures
fun h0 _ h1 ->
modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a)) | {
"checked_file": "Hacl.Bignum.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.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.Bignum.fsti"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Spec.Bignum.Definitions.limb",
"Prims.op_Addition",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_mul"
] | [] | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract
let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_add_mod_n_st t len
inline_for_extraction noextract
let bn_sub_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_sub_mod_n_st t len
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
b:lbignum t len
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_mul_st t len a
inline_for_extraction noextract
let bn_mul_st (t:limb_t) (aLen:size_t) (bLen:size_t{v aLen + v bLen <= max_size_t}) (a:lbignum t aLen) =
b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_mul:
#t:limb_t
-> aLen:size_t
-> bLen:size_t{v aLen + v bLen <= max_size_t}
-> a:lbignum t aLen ->
bn_mul_st t aLen bLen a
inline_for_extraction noextract | false | false | Hacl.Bignum.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_sqr_st : t: Hacl.Bignum.Definitions.limb_t ->
len:
Lib.IntTypes.size_t
{0 < Lib.IntTypes.v len /\ 4 * Lib.IntTypes.v len <= Lib.IntTypes.max_size_t} ->
a: Hacl.Bignum.Definitions.lbignum t len
-> Type0 | [] | Hacl.Bignum.bn_karatsuba_sqr_st | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Hacl.Bignum.Definitions.limb_t ->
len:
Lib.IntTypes.size_t
{0 < Lib.IntTypes.v len /\ 4 * Lib.IntTypes.v len <= Lib.IntTypes.max_size_t} ->
a: Hacl.Bignum.Definitions.lbignum t len
-> Type0 | {
"end_col": 58,
"end_line": 234,
"start_col": 2,
"start_line": 230
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_sqr_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a)) | let bn_sqr_st (t: limb_t) (len: size_t{0 < v len /\ v len + v len <= max_size_t}) (a: lbignum t len) = | false | null | false | res: lbignum t (len +! len)
-> Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures
fun h0 _ h1 ->
modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a)) | {
"checked_file": "Hacl.Bignum.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.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.Bignum.fsti"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.max_size_t",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Spec.Bignum.Definitions.limb",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_mul"
] | [] | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract
let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_add_mod_n_st t len
inline_for_extraction noextract
let bn_sub_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_sub_mod_n_st t len
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
b:lbignum t len
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_mul_st t len a
inline_for_extraction noextract
let bn_mul_st (t:limb_t) (aLen:size_t) (bLen:size_t{v aLen + v bLen <= max_size_t}) (a:lbignum t aLen) =
b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_mul:
#t:limb_t
-> aLen:size_t
-> bLen:size_t{v aLen + v bLen <= max_size_t}
-> a:lbignum t aLen ->
bn_mul_st t aLen bLen a
inline_for_extraction noextract
let bn_karatsuba_sqr_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a))
inline_for_extraction noextract
val bn_karatsuba_sqr:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_sqr_st t len a
inline_for_extraction noextract | false | false | Hacl.Bignum.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_sqr_st : t: Hacl.Bignum.Definitions.limb_t ->
len:
Lib.IntTypes.size_t
{ 0 < Lib.IntTypes.v len /\
Lib.IntTypes.v len + Lib.IntTypes.v len <= Lib.IntTypes.max_size_t } ->
a: Hacl.Bignum.Definitions.lbignum t len
-> Type0 | [] | Hacl.Bignum.bn_sqr_st | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Hacl.Bignum.Definitions.limb_t ->
len:
Lib.IntTypes.size_t
{ 0 < Lib.IntTypes.v len /\
Lib.IntTypes.v len + Lib.IntTypes.v len <= Lib.IntTypes.max_size_t } ->
a: Hacl.Bignum.Definitions.lbignum t len
-> Type0 | {
"end_col": 58,
"end_line": 251,
"start_col": 2,
"start_line": 247
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_eq_mask_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len ->
Stack (limb t)
(requires fun h -> live h a /\ live h b)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_eq_mask (as_seq h0 a) (as_seq h0 b)) | let bn_eq_mask_st (t: limb_t) (len: size_t) = | false | null | false | a: lbignum t len -> b: lbignum t len
-> Stack (limb t)
(requires fun h -> live h a /\ live h b)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_eq_mask (as_seq h0 a) (as_seq h0 b)) | {
"checked_file": "Hacl.Bignum.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.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.Bignum.fsti"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.modifies0",
"Prims.eq2",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.bn_eq_mask",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq"
] | [] | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract
let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_add_mod_n_st t len
inline_for_extraction noextract
let bn_sub_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_sub_mod_n_st t len
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
b:lbignum t len
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_mul_st t len a
inline_for_extraction noextract
let bn_mul_st (t:limb_t) (aLen:size_t) (bLen:size_t{v aLen + v bLen <= max_size_t}) (a:lbignum t aLen) =
b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_mul:
#t:limb_t
-> aLen:size_t
-> bLen:size_t{v aLen + v bLen <= max_size_t}
-> a:lbignum t aLen ->
bn_mul_st t aLen bLen a
inline_for_extraction noextract
let bn_karatsuba_sqr_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a))
inline_for_extraction noextract
val bn_karatsuba_sqr:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_sqr_st t len a
inline_for_extraction noextract
let bn_sqr_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a))
inline_for_extraction noextract
val bn_sqr:
#t:limb_t
-> len:size_t{0 < v len /\ v len + v len <= max_size_t}
-> a:lbignum t len ->
bn_sqr_st t len a
inline_for_extraction noextract
val bn_mul1_lshift_add_in_place:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> b:limb t
-> resLen:size_t
-> j:size_t{v j + v aLen <= v resLen}
-> res:lbignum t resLen ->
Stack (limb t)
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b (v j) (as_seq h0 res))
inline_for_extraction noextract
val bn_rshift:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i < v len}
-> res:lbignum t (len -! i) ->
Stack unit
(requires fun h -> live h b /\ live h res /\ disjoint res b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_rshift (as_seq h0 b) (v i))
inline_for_extraction noextract
val bn_sub_mask:
#t:limb_t
-> len:size_t{v len > 0}
-> n:lbignum t len
-> a:lbignum t len ->
Stack unit
(requires fun h -> live h n /\ live h a /\ disjoint n a)
(ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_sub_mask (as_seq h0 n) (as_seq h0 a))
///
/// Get and set i-th bit of a bignum
///
inline_for_extraction noextract
val bn_get_ith_bit:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i / bits t < v len} ->
Stack (limb t)
(requires fun h -> live h b)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.bn_get_ith_bit (as_seq h0 b) (v i))
inline_for_extraction noextract
val bn_get_bits:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t
-> l:size_t{v l < bits t /\ v i / bits t < v len} ->
Stack (limb t)
(requires fun h -> live h b)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.bn_get_bits (as_seq h0 b) (v i) (v l))
inline_for_extraction noextract
val bn_set_ith_bit:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i / bits t < v len} ->
Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
as_seq h1 b == S.bn_set_ith_bit (as_seq h0 b) (v i))
inline_for_extraction noextract
val cswap2:
#t:limb_t
-> len:size_t
-> bit:limb t
-> b1:lbignum t len
-> b2:lbignum t len ->
Stack unit
(requires fun h -> live h b1 /\ live h b2 /\ disjoint b1 b2)
(ensures fun h0 _ h1 -> modifies (loc b1 |+| loc b2) h0 h1 /\
(as_seq h1 b1, as_seq h1 b2) == S.cswap2 bit (as_seq h0 b1) (as_seq h0 b2))
/// Start of the len-based specialization infrastructure.
///
/// Essentially, we wish to describe a type class of basic bignum operations
/// needed to implement Montgomery reduction. This will allow us to generate
/// specialized versions of modular exponentiation for a given bignum size.
///
/// This is done "by hand" because the specialization pattern is more
/// complicated than other pieces of code (chacha, poly, curve), meaning I don't
/// (yet) know how to automate it with a tactic. So, a type class seems like the
/// most efficient way to go about it.
///
/// The operations of the type class were found by essentially reading the code,
/// writing down which operations from Hacl.Bignum are (transitively) needed to
/// implement modular exponentiation, and figuring out for each call-site
/// whether they can be specialized for the bignum size, or whether they have to
/// been inline-for-extraction'd.
inline_for_extraction noextract
let meta_len (t:limb_t) = len:size_t{0 < v len /\ 2 * bits t * v len <= max_size_t}
/// This type class is entirely meta-level and will not appear after partial
/// evaluation in the resulting C code. Clients can take this type class as a
/// parameter if they want the benefits of a function set specialized for a
/// given bignum length.
inline_for_extraction noextract
class bn (t:limb_t) = {
len: meta_len t;
add: bn_add_eq_len_st t len;
sub: bn_sub_eq_len_st t len;
add_mod_n: bn_add_mod_n_st t len;
sub_mod_n: bn_sub_mod_n_st t len;
mul: a:lbignum t len -> bn_karatsuba_mul_st t len a;
sqr: a:lbignum t len -> bn_karatsuba_sqr_st t len a;
}
inline_for_extraction noextract
val mk_runtime_bn: t:limb_t -> len:meta_len t -> bn t
val mk_runtime_bn_len_lemma: t:limb_t -> len:meta_len t ->
Lemma ((mk_runtime_bn t len).len == len) [SMTPat (mk_runtime_bn t len)]
///
/// Bignum comparison and test functions
///
inline_for_extraction noextract
val bn_is_odd:
#t:limb_t
-> len:size_t{v len > 0}
-> a:lbignum t len ->
Stack (limb t)
(requires fun h -> live h a)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_is_odd (as_seq h0 a))
inline_for_extraction noextract | false | true | Hacl.Bignum.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_eq_mask_st : t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0 | [] | Hacl.Bignum.bn_eq_mask_st | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0 | {
"end_col": 50,
"end_line": 419,
"start_col": 4,
"start_line": 414
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_lt_mask_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len ->
Stack (limb t)
(requires fun h -> live h a /\ live h b)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_lt_mask (as_seq h0 a) (as_seq h0 b)) | let bn_lt_mask_st (t: limb_t) (len: size_t) = | false | null | false | a: lbignum t len -> b: lbignum t len
-> Stack (limb t)
(requires fun h -> live h a /\ live h b)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_lt_mask (as_seq h0 a) (as_seq h0 b)) | {
"checked_file": "Hacl.Bignum.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.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.Bignum.fsti"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.modifies0",
"Prims.eq2",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.bn_lt_mask",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq"
] | [] | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract
let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_add_mod_n_st t len
inline_for_extraction noextract
let bn_sub_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_sub_mod_n_st t len
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
b:lbignum t len
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_mul_st t len a
inline_for_extraction noextract
let bn_mul_st (t:limb_t) (aLen:size_t) (bLen:size_t{v aLen + v bLen <= max_size_t}) (a:lbignum t aLen) =
b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_mul:
#t:limb_t
-> aLen:size_t
-> bLen:size_t{v aLen + v bLen <= max_size_t}
-> a:lbignum t aLen ->
bn_mul_st t aLen bLen a
inline_for_extraction noextract
let bn_karatsuba_sqr_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a))
inline_for_extraction noextract
val bn_karatsuba_sqr:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_sqr_st t len a
inline_for_extraction noextract
let bn_sqr_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a))
inline_for_extraction noextract
val bn_sqr:
#t:limb_t
-> len:size_t{0 < v len /\ v len + v len <= max_size_t}
-> a:lbignum t len ->
bn_sqr_st t len a
inline_for_extraction noextract
val bn_mul1_lshift_add_in_place:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> b:limb t
-> resLen:size_t
-> j:size_t{v j + v aLen <= v resLen}
-> res:lbignum t resLen ->
Stack (limb t)
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b (v j) (as_seq h0 res))
inline_for_extraction noextract
val bn_rshift:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i < v len}
-> res:lbignum t (len -! i) ->
Stack unit
(requires fun h -> live h b /\ live h res /\ disjoint res b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_rshift (as_seq h0 b) (v i))
inline_for_extraction noextract
val bn_sub_mask:
#t:limb_t
-> len:size_t{v len > 0}
-> n:lbignum t len
-> a:lbignum t len ->
Stack unit
(requires fun h -> live h n /\ live h a /\ disjoint n a)
(ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_sub_mask (as_seq h0 n) (as_seq h0 a))
///
/// Get and set i-th bit of a bignum
///
inline_for_extraction noextract
val bn_get_ith_bit:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i / bits t < v len} ->
Stack (limb t)
(requires fun h -> live h b)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.bn_get_ith_bit (as_seq h0 b) (v i))
inline_for_extraction noextract
val bn_get_bits:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t
-> l:size_t{v l < bits t /\ v i / bits t < v len} ->
Stack (limb t)
(requires fun h -> live h b)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.bn_get_bits (as_seq h0 b) (v i) (v l))
inline_for_extraction noextract
val bn_set_ith_bit:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i / bits t < v len} ->
Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
as_seq h1 b == S.bn_set_ith_bit (as_seq h0 b) (v i))
inline_for_extraction noextract
val cswap2:
#t:limb_t
-> len:size_t
-> bit:limb t
-> b1:lbignum t len
-> b2:lbignum t len ->
Stack unit
(requires fun h -> live h b1 /\ live h b2 /\ disjoint b1 b2)
(ensures fun h0 _ h1 -> modifies (loc b1 |+| loc b2) h0 h1 /\
(as_seq h1 b1, as_seq h1 b2) == S.cswap2 bit (as_seq h0 b1) (as_seq h0 b2))
/// Start of the len-based specialization infrastructure.
///
/// Essentially, we wish to describe a type class of basic bignum operations
/// needed to implement Montgomery reduction. This will allow us to generate
/// specialized versions of modular exponentiation for a given bignum size.
///
/// This is done "by hand" because the specialization pattern is more
/// complicated than other pieces of code (chacha, poly, curve), meaning I don't
/// (yet) know how to automate it with a tactic. So, a type class seems like the
/// most efficient way to go about it.
///
/// The operations of the type class were found by essentially reading the code,
/// writing down which operations from Hacl.Bignum are (transitively) needed to
/// implement modular exponentiation, and figuring out for each call-site
/// whether they can be specialized for the bignum size, or whether they have to
/// been inline-for-extraction'd.
inline_for_extraction noextract
let meta_len (t:limb_t) = len:size_t{0 < v len /\ 2 * bits t * v len <= max_size_t}
/// This type class is entirely meta-level and will not appear after partial
/// evaluation in the resulting C code. Clients can take this type class as a
/// parameter if they want the benefits of a function set specialized for a
/// given bignum length.
inline_for_extraction noextract
class bn (t:limb_t) = {
len: meta_len t;
add: bn_add_eq_len_st t len;
sub: bn_sub_eq_len_st t len;
add_mod_n: bn_add_mod_n_st t len;
sub_mod_n: bn_sub_mod_n_st t len;
mul: a:lbignum t len -> bn_karatsuba_mul_st t len a;
sqr: a:lbignum t len -> bn_karatsuba_sqr_st t len a;
}
inline_for_extraction noextract
val mk_runtime_bn: t:limb_t -> len:meta_len t -> bn t
val mk_runtime_bn_len_lemma: t:limb_t -> len:meta_len t ->
Lemma ((mk_runtime_bn t len).len == len) [SMTPat (mk_runtime_bn t len)]
///
/// Bignum comparison and test functions
///
inline_for_extraction noextract
val bn_is_odd:
#t:limb_t
-> len:size_t{v len > 0}
-> a:lbignum t len ->
Stack (limb t)
(requires fun h -> live h a)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_is_odd (as_seq h0 a))
inline_for_extraction noextract
let bn_eq_mask_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len ->
Stack (limb t)
(requires fun h -> live h a /\ live h b)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_eq_mask (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_eq_mask: #t:limb_t -> len:size_t -> bn_eq_mask_st t len
inline_for_extraction noextract
val bn_is_zero_mask:
#t:limb_t
-> len:size_t{v len > 0}
-> a:lbignum t len ->
Stack (limb t)
(requires fun h -> live h a)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_is_zero_mask (as_seq h0 a))
inline_for_extraction noextract | false | true | Hacl.Bignum.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_lt_mask_st : t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0 | [] | Hacl.Bignum.bn_lt_mask_st | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0 | {
"end_col": 50,
"end_line": 444,
"start_col": 4,
"start_line": 439
} |
|
Prims.Tot | val ffdhe_g2:x: glbuffer pub_uint8 1ul {witnessed x S.ffdhe_g2 /\ recallable x} | [
{
"abbrev": true,
"full_module": "Spec.FFDHE",
"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.FFDHE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.FFDHE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ffdhe_g2 :x:glbuffer pub_uint8 1ul{witnessed x S.ffdhe_g2 /\ recallable x} =
createL_global S.list_ffdhe_g2 | val ffdhe_g2:x: glbuffer pub_uint8 1ul {witnessed x S.ffdhe_g2 /\ recallable x}
let ffdhe_g2:x: glbuffer pub_uint8 1ul {witnessed x S.ffdhe_g2 /\ recallable x} = | false | null | false | createL_global S.list_ffdhe_g2 | {
"checked_file": "Hacl.Impl.FFDHE.Constants.fst.checked",
"dependencies": [
"Spec.FFDHE.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.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.FFDHE.Constants.fst"
} | [
"total"
] | [
"Lib.Buffer.createL_global",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.PUB",
"Spec.FFDHE.list_ffdhe_g2",
"Lib.Buffer.glbuffer",
"Lib.IntTypes.size",
"FStar.Pervasives.normalize_term",
"Lib.IntTypes.size_nat",
"FStar.List.Tot.Base.length"
] | [] | module Hacl.Impl.FFDHE.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.FFDHE
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | false | Hacl.Impl.FFDHE.Constants.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ffdhe_g2:x: glbuffer pub_uint8 1ul {witnessed x S.ffdhe_g2 /\ recallable x} | [] | Hacl.Impl.FFDHE.Constants.ffdhe_g2 | {
"file_name": "code/ffdhe/Hacl.Impl.FFDHE.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x:
(c:
Lib.Buffer.lbuffer_t Lib.Buffer.CONST
(Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.PUB)
(FStar.UInt32.uint_to_t 1 <: FStar.UInt32.t)
{LowStar.ConstBuffer.qual_of c == LowStar.ConstBuffer.IMMUTABLE})
{Lib.Buffer.witnessed x Spec.FFDHE.ffdhe_g2 /\ Lib.Buffer.recallable x} | {
"end_col": 32,
"end_line": 16,
"start_col": 2,
"start_line": 16
} |
Prims.Tot | val ffdhe_p2048:x: glbuffer pub_uint8 256ul {witnessed x S.ffdhe_p2048 /\ recallable x} | [
{
"abbrev": true,
"full_module": "Spec.FFDHE",
"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.FFDHE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.FFDHE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ffdhe_p2048 :x:glbuffer pub_uint8 256ul{witnessed x S.ffdhe_p2048 /\ recallable x} =
createL_global S.list_ffdhe_p2048 | val ffdhe_p2048:x: glbuffer pub_uint8 256ul {witnessed x S.ffdhe_p2048 /\ recallable x}
let ffdhe_p2048:x: glbuffer pub_uint8 256ul {witnessed x S.ffdhe_p2048 /\ recallable x} = | false | null | false | createL_global S.list_ffdhe_p2048 | {
"checked_file": "Hacl.Impl.FFDHE.Constants.fst.checked",
"dependencies": [
"Spec.FFDHE.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.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.FFDHE.Constants.fst"
} | [
"total"
] | [
"Lib.Buffer.createL_global",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.PUB",
"Spec.FFDHE.list_ffdhe_p2048",
"Lib.Buffer.glbuffer",
"Lib.IntTypes.size",
"FStar.Pervasives.normalize_term",
"Lib.IntTypes.size_nat",
"FStar.List.Tot.Base.length"
] | [] | module Hacl.Impl.FFDHE.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.FFDHE
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let ffdhe_g2 :x:glbuffer pub_uint8 1ul{witnessed x S.ffdhe_g2 /\ recallable x} =
createL_global S.list_ffdhe_g2 | false | false | Hacl.Impl.FFDHE.Constants.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ffdhe_p2048:x: glbuffer pub_uint8 256ul {witnessed x S.ffdhe_p2048 /\ recallable x} | [] | Hacl.Impl.FFDHE.Constants.ffdhe_p2048 | {
"file_name": "code/ffdhe/Hacl.Impl.FFDHE.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x:
(c:
Lib.Buffer.lbuffer_t Lib.Buffer.CONST
(Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.PUB)
(FStar.UInt32.uint_to_t 256 <: FStar.UInt32.t)
{LowStar.ConstBuffer.qual_of c == LowStar.ConstBuffer.IMMUTABLE})
{Lib.Buffer.witnessed x Spec.FFDHE.ffdhe_p2048 /\ Lib.Buffer.recallable x} | {
"end_col": 35,
"end_line": 19,
"start_col": 2,
"start_line": 19
} |
Prims.Tot | val ffdhe_p3072:x: glbuffer pub_uint8 384ul {witnessed x S.ffdhe_p3072 /\ recallable x} | [
{
"abbrev": true,
"full_module": "Spec.FFDHE",
"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.FFDHE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.FFDHE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ffdhe_p3072 :x:glbuffer pub_uint8 384ul{witnessed x S.ffdhe_p3072 /\ recallable x} =
createL_global S.list_ffdhe_p3072 | val ffdhe_p3072:x: glbuffer pub_uint8 384ul {witnessed x S.ffdhe_p3072 /\ recallable x}
let ffdhe_p3072:x: glbuffer pub_uint8 384ul {witnessed x S.ffdhe_p3072 /\ recallable x} = | false | null | false | createL_global S.list_ffdhe_p3072 | {
"checked_file": "Hacl.Impl.FFDHE.Constants.fst.checked",
"dependencies": [
"Spec.FFDHE.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.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.FFDHE.Constants.fst"
} | [
"total"
] | [
"Lib.Buffer.createL_global",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.PUB",
"Spec.FFDHE.list_ffdhe_p3072",
"Lib.Buffer.glbuffer",
"Lib.IntTypes.size",
"FStar.Pervasives.normalize_term",
"Lib.IntTypes.size_nat",
"FStar.List.Tot.Base.length"
] | [] | module Hacl.Impl.FFDHE.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.FFDHE
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let ffdhe_g2 :x:glbuffer pub_uint8 1ul{witnessed x S.ffdhe_g2 /\ recallable x} =
createL_global S.list_ffdhe_g2
let ffdhe_p2048 :x:glbuffer pub_uint8 256ul{witnessed x S.ffdhe_p2048 /\ recallable x} =
createL_global S.list_ffdhe_p2048 | false | false | Hacl.Impl.FFDHE.Constants.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ffdhe_p3072:x: glbuffer pub_uint8 384ul {witnessed x S.ffdhe_p3072 /\ recallable x} | [] | Hacl.Impl.FFDHE.Constants.ffdhe_p3072 | {
"file_name": "code/ffdhe/Hacl.Impl.FFDHE.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x:
(c:
Lib.Buffer.lbuffer_t Lib.Buffer.CONST
(Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.PUB)
(FStar.UInt32.uint_to_t 384 <: FStar.UInt32.t)
{LowStar.ConstBuffer.qual_of c == LowStar.ConstBuffer.IMMUTABLE})
{Lib.Buffer.witnessed x Spec.FFDHE.ffdhe_p3072 /\ Lib.Buffer.recallable x} | {
"end_col": 35,
"end_line": 22,
"start_col": 2,
"start_line": 22
} |
Prims.Tot | val ffdhe_p4096:x: glbuffer pub_uint8 512ul {witnessed x S.ffdhe_p4096 /\ recallable x} | [
{
"abbrev": true,
"full_module": "Spec.FFDHE",
"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.FFDHE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.FFDHE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ffdhe_p4096 :x:glbuffer pub_uint8 512ul{witnessed x S.ffdhe_p4096 /\ recallable x} =
createL_global S.list_ffdhe_p4096 | val ffdhe_p4096:x: glbuffer pub_uint8 512ul {witnessed x S.ffdhe_p4096 /\ recallable x}
let ffdhe_p4096:x: glbuffer pub_uint8 512ul {witnessed x S.ffdhe_p4096 /\ recallable x} = | false | null | false | createL_global S.list_ffdhe_p4096 | {
"checked_file": "Hacl.Impl.FFDHE.Constants.fst.checked",
"dependencies": [
"Spec.FFDHE.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.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.FFDHE.Constants.fst"
} | [
"total"
] | [
"Lib.Buffer.createL_global",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.PUB",
"Spec.FFDHE.list_ffdhe_p4096",
"Lib.Buffer.glbuffer",
"Lib.IntTypes.size",
"FStar.Pervasives.normalize_term",
"Lib.IntTypes.size_nat",
"FStar.List.Tot.Base.length"
] | [] | module Hacl.Impl.FFDHE.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.FFDHE
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let ffdhe_g2 :x:glbuffer pub_uint8 1ul{witnessed x S.ffdhe_g2 /\ recallable x} =
createL_global S.list_ffdhe_g2
let ffdhe_p2048 :x:glbuffer pub_uint8 256ul{witnessed x S.ffdhe_p2048 /\ recallable x} =
createL_global S.list_ffdhe_p2048
let ffdhe_p3072 :x:glbuffer pub_uint8 384ul{witnessed x S.ffdhe_p3072 /\ recallable x} =
createL_global S.list_ffdhe_p3072 | false | false | Hacl.Impl.FFDHE.Constants.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ffdhe_p4096:x: glbuffer pub_uint8 512ul {witnessed x S.ffdhe_p4096 /\ recallable x} | [] | Hacl.Impl.FFDHE.Constants.ffdhe_p4096 | {
"file_name": "code/ffdhe/Hacl.Impl.FFDHE.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x:
(c:
Lib.Buffer.lbuffer_t Lib.Buffer.CONST
(Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.PUB)
(FStar.UInt32.uint_to_t 512 <: FStar.UInt32.t)
{LowStar.ConstBuffer.qual_of c == LowStar.ConstBuffer.IMMUTABLE})
{Lib.Buffer.witnessed x Spec.FFDHE.ffdhe_p4096 /\ Lib.Buffer.recallable x} | {
"end_col": 35,
"end_line": 25,
"start_col": 2,
"start_line": 25
} |
Prims.Tot | val ffdhe_p6144:x: glbuffer pub_uint8 768ul {witnessed x S.ffdhe_p6144 /\ recallable x} | [
{
"abbrev": true,
"full_module": "Spec.FFDHE",
"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.FFDHE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.FFDHE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ffdhe_p6144 :x:glbuffer pub_uint8 768ul{witnessed x S.ffdhe_p6144 /\ recallable x} =
createL_global S.list_ffdhe_p6144 | val ffdhe_p6144:x: glbuffer pub_uint8 768ul {witnessed x S.ffdhe_p6144 /\ recallable x}
let ffdhe_p6144:x: glbuffer pub_uint8 768ul {witnessed x S.ffdhe_p6144 /\ recallable x} = | false | null | false | createL_global S.list_ffdhe_p6144 | {
"checked_file": "Hacl.Impl.FFDHE.Constants.fst.checked",
"dependencies": [
"Spec.FFDHE.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.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.FFDHE.Constants.fst"
} | [
"total"
] | [
"Lib.Buffer.createL_global",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.PUB",
"Spec.FFDHE.list_ffdhe_p6144",
"Lib.Buffer.glbuffer",
"Lib.IntTypes.size",
"FStar.Pervasives.normalize_term",
"Lib.IntTypes.size_nat",
"FStar.List.Tot.Base.length"
] | [] | module Hacl.Impl.FFDHE.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.FFDHE
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let ffdhe_g2 :x:glbuffer pub_uint8 1ul{witnessed x S.ffdhe_g2 /\ recallable x} =
createL_global S.list_ffdhe_g2
let ffdhe_p2048 :x:glbuffer pub_uint8 256ul{witnessed x S.ffdhe_p2048 /\ recallable x} =
createL_global S.list_ffdhe_p2048
let ffdhe_p3072 :x:glbuffer pub_uint8 384ul{witnessed x S.ffdhe_p3072 /\ recallable x} =
createL_global S.list_ffdhe_p3072
let ffdhe_p4096 :x:glbuffer pub_uint8 512ul{witnessed x S.ffdhe_p4096 /\ recallable x} =
createL_global S.list_ffdhe_p4096 | false | false | Hacl.Impl.FFDHE.Constants.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ffdhe_p6144:x: glbuffer pub_uint8 768ul {witnessed x S.ffdhe_p6144 /\ recallable x} | [] | Hacl.Impl.FFDHE.Constants.ffdhe_p6144 | {
"file_name": "code/ffdhe/Hacl.Impl.FFDHE.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x:
(c:
Lib.Buffer.lbuffer_t Lib.Buffer.CONST
(Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.PUB)
(FStar.UInt32.uint_to_t 768 <: FStar.UInt32.t)
{LowStar.ConstBuffer.qual_of c == LowStar.ConstBuffer.IMMUTABLE})
{Lib.Buffer.witnessed x Spec.FFDHE.ffdhe_p6144 /\ Lib.Buffer.recallable x} | {
"end_col": 35,
"end_line": 28,
"start_col": 2,
"start_line": 28
} |
Prims.Tot | val ffdhe_p8192:x: glbuffer pub_uint8 1024ul {witnessed x S.ffdhe_p8192 /\ recallable x} | [
{
"abbrev": true,
"full_module": "Spec.FFDHE",
"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.FFDHE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.FFDHE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ffdhe_p8192 :x:glbuffer pub_uint8 1024ul{witnessed x S.ffdhe_p8192 /\ recallable x} =
createL_global S.list_ffdhe_p8192 | val ffdhe_p8192:x: glbuffer pub_uint8 1024ul {witnessed x S.ffdhe_p8192 /\ recallable x}
let ffdhe_p8192:x: glbuffer pub_uint8 1024ul {witnessed x S.ffdhe_p8192 /\ recallable x} = | false | null | false | createL_global S.list_ffdhe_p8192 | {
"checked_file": "Hacl.Impl.FFDHE.Constants.fst.checked",
"dependencies": [
"Spec.FFDHE.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.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.FFDHE.Constants.fst"
} | [
"total"
] | [
"Lib.Buffer.createL_global",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.PUB",
"Spec.FFDHE.list_ffdhe_p8192",
"Lib.Buffer.glbuffer",
"Lib.IntTypes.size",
"FStar.Pervasives.normalize_term",
"Lib.IntTypes.size_nat",
"FStar.List.Tot.Base.length"
] | [] | module Hacl.Impl.FFDHE.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.FFDHE
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let ffdhe_g2 :x:glbuffer pub_uint8 1ul{witnessed x S.ffdhe_g2 /\ recallable x} =
createL_global S.list_ffdhe_g2
let ffdhe_p2048 :x:glbuffer pub_uint8 256ul{witnessed x S.ffdhe_p2048 /\ recallable x} =
createL_global S.list_ffdhe_p2048
let ffdhe_p3072 :x:glbuffer pub_uint8 384ul{witnessed x S.ffdhe_p3072 /\ recallable x} =
createL_global S.list_ffdhe_p3072
let ffdhe_p4096 :x:glbuffer pub_uint8 512ul{witnessed x S.ffdhe_p4096 /\ recallable x} =
createL_global S.list_ffdhe_p4096
let ffdhe_p6144 :x:glbuffer pub_uint8 768ul{witnessed x S.ffdhe_p6144 /\ recallable x} =
createL_global S.list_ffdhe_p6144 | false | false | Hacl.Impl.FFDHE.Constants.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ffdhe_p8192:x: glbuffer pub_uint8 1024ul {witnessed x S.ffdhe_p8192 /\ recallable x} | [] | Hacl.Impl.FFDHE.Constants.ffdhe_p8192 | {
"file_name": "code/ffdhe/Hacl.Impl.FFDHE.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x:
(c:
Lib.Buffer.lbuffer_t Lib.Buffer.CONST
(Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.PUB)
(FStar.UInt32.uint_to_t 1024 <: FStar.UInt32.t)
{LowStar.ConstBuffer.qual_of c == LowStar.ConstBuffer.IMMUTABLE})
{Lib.Buffer.witnessed x Spec.FFDHE.ffdhe_p8192 /\ Lib.Buffer.recallable x} | {
"end_col": 35,
"end_line": 31,
"start_col": 2,
"start_line": 31
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let vale_p = Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled) | let vale_p = | false | null | false | let open Vale.X64.CPU_Features_s in adx_enabled /\ bmi2_enabled | {
"checked_file": "Hacl.HPKE.Curve64_CP128_SHA256.fsti.checked",
"dependencies": [
"Vale.X64.CPU_Features_s.fst.checked",
"Spec.Agile.HPKE.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Hacl.Impl.HPKE.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.HPKE.Curve64_CP128_SHA256.fsti"
} | [
"total"
] | [
"Prims.l_and",
"Prims.b2t",
"Vale.X64.CPU_Features_s.adx_enabled",
"Vale.X64.CPU_Features_s.bmi2_enabled"
] | [] | module Hacl.HPKE.Curve64_CP128_SHA256
open Hacl.Impl.HPKE
module S = Spec.Agile.HPKE
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
noextract unfold
let cs:S.ciphersuite = (DH.DH_Curve25519, Hash.SHA2_256, S.Seal AEAD.CHACHA20_POLY1305, Hash.SHA2_256) | false | true | Hacl.HPKE.Curve64_CP128_SHA256.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val vale_p : Prims.logical | [] | Hacl.HPKE.Curve64_CP128_SHA256.vale_p | {
"file_name": "code/hpke/Hacl.HPKE.Curve64_CP128_SHA256.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.logical | {
"end_col": 65,
"end_line": 13,
"start_col": 38,
"start_line": 13
} |
|
Prims.Tot | val cs:S.ciphersuite | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let cs:S.ciphersuite = (DH.DH_Curve25519, Hash.SHA2_256, S.Seal AEAD.CHACHA20_POLY1305, Hash.SHA2_256) | val cs:S.ciphersuite
let cs:S.ciphersuite = | false | null | false | (DH.DH_Curve25519, Hash.SHA2_256, S.Seal AEAD.CHACHA20_POLY1305, Hash.SHA2_256) | {
"checked_file": "Hacl.HPKE.Curve64_CP128_SHA256.fsti.checked",
"dependencies": [
"Vale.X64.CPU_Features_s.fst.checked",
"Spec.Agile.HPKE.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Hacl.Impl.HPKE.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.HPKE.Curve64_CP128_SHA256.fsti"
} | [
"total"
] | [
"FStar.Pervasives.Native.Mktuple4",
"Spec.Agile.DH.algorithm",
"Spec.Agile.HPKE.hash_algorithm",
"Spec.Agile.HPKE.aead",
"Spec.Hash.Definitions.hash_alg",
"Spec.Agile.DH.DH_Curve25519",
"Spec.Hash.Definitions.SHA2_256",
"Spec.Agile.HPKE.Seal",
"Spec.Agile.AEAD.CHACHA20_POLY1305"
] | [] | module Hacl.HPKE.Curve64_CP128_SHA256
open Hacl.Impl.HPKE
module S = Spec.Agile.HPKE
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash | false | true | Hacl.HPKE.Curve64_CP128_SHA256.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val cs:S.ciphersuite | [] | Hacl.HPKE.Curve64_CP128_SHA256.cs | {
"file_name": "code/hpke/Hacl.HPKE.Curve64_CP128_SHA256.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Spec.Agile.HPKE.ciphersuite | {
"end_col": 102,
"end_line": 10,
"start_col": 23,
"start_line": 10
} |
Prims.Tot | val expand (a: cipher_alg) (k: key a) : xkey a | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let expand (a: cipher_alg) (k: key a): xkey a =
match a with
| AES128 | AES256 -> Spec.AES.aes_key_expansion (aes_alg_of_alg a) k
| CHACHA20 -> k | val expand (a: cipher_alg) (k: key a) : xkey a
let expand (a: cipher_alg) (k: key a) : xkey a = | false | null | false | match a with
| AES128 | AES256 -> Spec.AES.aes_key_expansion (aes_alg_of_alg a) k
| CHACHA20 -> k | {
"checked_file": "Spec.Agile.Cipher.fst.checked",
"dependencies": [
"Spec.Chacha20.fst.checked",
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Spec.Agile.Cipher.fst"
} | [
"total"
] | [
"Spec.Agile.Cipher.cipher_alg",
"Spec.Agile.Cipher.key",
"Spec.AES.aes_key_expansion",
"Spec.Agile.Cipher.aes_alg_of_alg",
"Spec.Agile.Cipher.xkey"
] | [] | module Spec.Agile.Cipher
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
let force_flush_interleaving = ()
let aes_ctr_block_add_counter (block: lbytes 16) (incr:size_nat): Tot (lbytes 16) =
let n = nat_from_bytes_be block in
let n' = (n + incr) % pow2 128 in
nat_to_bytes_be 16 n'
let xkey (a: cipher_alg) =
match a with
| AES128 | AES256 -> Spec.AES.aes_xkey (aes_alg_of_alg a)
| CHACHA20 -> Spec.Chacha20.key
/// As specified by the NIST. Other implementations (e.g. Vale) may perform
/// other steps beyond key expansion but this is an implementation detail. | false | false | Spec.Agile.Cipher.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val expand (a: cipher_alg) (k: key a) : xkey a | [] | Spec.Agile.Cipher.expand | {
"file_name": "specs/Spec.Agile.Cipher.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Agile.Cipher.cipher_alg -> k: Spec.Agile.Cipher.key a -> Spec.Agile.Cipher.xkey a | {
"end_col": 17,
"end_line": 27,
"start_col": 2,
"start_line": 25
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let xkey (a: cipher_alg) =
match a with
| AES128 | AES256 -> Spec.AES.aes_xkey (aes_alg_of_alg a)
| CHACHA20 -> Spec.Chacha20.key | let xkey (a: cipher_alg) = | false | null | false | match a with
| AES128 | AES256 -> Spec.AES.aes_xkey (aes_alg_of_alg a)
| CHACHA20 -> Spec.Chacha20.key | {
"checked_file": "Spec.Agile.Cipher.fst.checked",
"dependencies": [
"Spec.Chacha20.fst.checked",
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Spec.Agile.Cipher.fst"
} | [
"total"
] | [
"Spec.Agile.Cipher.cipher_alg",
"Spec.AES.aes_xkey",
"Spec.Agile.Cipher.aes_alg_of_alg",
"Spec.Chacha20.key"
] | [] | module Spec.Agile.Cipher
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
let force_flush_interleaving = ()
let aes_ctr_block_add_counter (block: lbytes 16) (incr:size_nat): Tot (lbytes 16) =
let n = nat_from_bytes_be block in
let n' = (n + incr) % pow2 128 in
nat_to_bytes_be 16 n' | false | true | Spec.Agile.Cipher.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val xkey : a: Spec.Agile.Cipher.cipher_alg -> Type0 | [] | Spec.Agile.Cipher.xkey | {
"file_name": "specs/Spec.Agile.Cipher.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Agile.Cipher.cipher_alg -> Type0 | {
"end_col": 33,
"end_line": 20,
"start_col": 2,
"start_line": 18
} |
|
Prims.Tot | val ctr_block (a: cipher_alg) (k: key a) (iv: nonce a) (c: ctr): block a | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ctr_block (a: cipher_alg) (k: key a) (iv: nonce a) (c: ctr): block a =
let k = expand a k in
match a with
| AES128 | AES256 ->
let open Spec.AES in
let open Lib.LoopCombinators in
let block = create 16 (u8 0) in
let block = repeati #(lbytes 16) (length iv) (fun i b -> b.[i] <- Seq.index iv i) block in
let block = aes_ctr_block_add_counter block c in
aes_encrypt_block (aes_alg_of_alg a) k block
| CHACHA20 ->
let open Spec.Chacha20 in
let block = chacha20_init k iv c in
let block' = rounds block in
uints_to_bytes_le (sum_state block block') | val ctr_block (a: cipher_alg) (k: key a) (iv: nonce a) (c: ctr): block a
let ctr_block (a: cipher_alg) (k: key a) (iv: nonce a) (c: ctr) : block a = | false | null | false | let k = expand a k in
match a with
| AES128
| AES256 ->
let open Spec.AES in
let open Lib.LoopCombinators in
let block = create 16 (u8 0) in
let block = repeati #(lbytes 16) (length iv) (fun i b -> b.[ i ] <- Seq.index iv i) block in
let block = aes_ctr_block_add_counter block c in
aes_encrypt_block (aes_alg_of_alg a) k block
| CHACHA20 ->
let open Spec.Chacha20 in
let block = chacha20_init k iv c in
let block' = rounds block in
uints_to_bytes_le (sum_state block block') | {
"checked_file": "Spec.Agile.Cipher.fst.checked",
"dependencies": [
"Spec.Chacha20.fst.checked",
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Spec.Agile.Cipher.fst"
} | [
"total"
] | [
"Spec.Agile.Cipher.cipher_alg",
"Spec.Agile.Cipher.key",
"Spec.Agile.Cipher.nonce",
"Spec.Agile.Cipher.ctr",
"Spec.AES.aes_encrypt_block",
"Spec.Agile.Cipher.aes_alg_of_alg",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.Cipher.aes_ctr_block_add_counter",
"Lib.LoopCombinators.repeati",
"Lib.ByteSequence.lbytes",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.Sequence.op_String_Assignment",
"FStar.Seq.Base.index",
"Prims.l_and",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Prims.l_Forall",
"Prims.l_imp",
"Lib.Sequence.index",
"Lib.Sequence.create",
"Lib.IntTypes.u8",
"Lib.ByteSequence.uints_to_bytes_le",
"Lib.IntTypes.U32",
"Spec.Chacha20.sum_state",
"Spec.Chacha20.state",
"Spec.Chacha20.rounds",
"Spec.Chacha20.chacha20_init",
"Spec.Agile.Cipher.block",
"Spec.Agile.Cipher.xkey",
"Spec.Agile.Cipher.expand"
] | [] | module Spec.Agile.Cipher
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
let force_flush_interleaving = ()
let aes_ctr_block_add_counter (block: lbytes 16) (incr:size_nat): Tot (lbytes 16) =
let n = nat_from_bytes_be block in
let n' = (n + incr) % pow2 128 in
nat_to_bytes_be 16 n'
let xkey (a: cipher_alg) =
match a with
| AES128 | AES256 -> Spec.AES.aes_xkey (aes_alg_of_alg a)
| CHACHA20 -> Spec.Chacha20.key
/// As specified by the NIST. Other implementations (e.g. Vale) may perform
/// other steps beyond key expansion but this is an implementation detail.
let expand (a: cipher_alg) (k: key a): xkey a =
match a with
| AES128 | AES256 -> Spec.AES.aes_key_expansion (aes_alg_of_alg a) k
| CHACHA20 -> k | false | false | Spec.Agile.Cipher.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ctr_block (a: cipher_alg) (k: key a) (iv: nonce a) (c: ctr): block a | [] | Spec.Agile.Cipher.ctr_block | {
"file_name": "specs/Spec.Agile.Cipher.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Agile.Cipher.cipher_alg ->
k: Spec.Agile.Cipher.key a ->
iv: Spec.Agile.Cipher.nonce a ->
c: Spec.Agile.Cipher.ctr
-> Spec.Agile.Cipher.block a | {
"end_col": 48,
"end_line": 45,
"start_col": 74,
"start_line": 30
} |
Prims.Tot | val aes_ctr_block_add_counter (block: lbytes 16) (incr: size_nat) : Tot (lbytes 16) | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aes_ctr_block_add_counter (block: lbytes 16) (incr:size_nat): Tot (lbytes 16) =
let n = nat_from_bytes_be block in
let n' = (n + incr) % pow2 128 in
nat_to_bytes_be 16 n' | val aes_ctr_block_add_counter (block: lbytes 16) (incr: size_nat) : Tot (lbytes 16)
let aes_ctr_block_add_counter (block: lbytes 16) (incr: size_nat) : Tot (lbytes 16) = | false | null | false | let n = nat_from_bytes_be block in
let n' = (n + incr) % pow2 128 in
nat_to_bytes_be 16 n' | {
"checked_file": "Spec.Agile.Cipher.fst.checked",
"dependencies": [
"Spec.Chacha20.fst.checked",
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Spec.Agile.Cipher.fst"
} | [
"total"
] | [
"Lib.ByteSequence.lbytes",
"Lib.IntTypes.size_nat",
"Lib.ByteSequence.nat_to_bytes_be",
"Lib.IntTypes.SEC",
"Prims.int",
"Prims.op_Modulus",
"Prims.op_Addition",
"Prims.pow2",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Multiply",
"Lib.Sequence.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.ByteSequence.nat_from_bytes_be"
] | [] | module Spec.Agile.Cipher
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
let force_flush_interleaving = () | false | false | Spec.Agile.Cipher.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aes_ctr_block_add_counter (block: lbytes 16) (incr: size_nat) : Tot (lbytes 16) | [] | Spec.Agile.Cipher.aes_ctr_block_add_counter | {
"file_name": "specs/Spec.Agile.Cipher.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | block: Lib.ByteSequence.lbytes 16 -> incr: Lib.IntTypes.size_nat -> Lib.ByteSequence.lbytes 16 | {
"end_col": 23,
"end_line": 15,
"start_col": 83,
"start_line": 12
} |
Prims.Tot | val va_code_Add64Wrap : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src)) | val va_code_Add64Wrap : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code
let va_code_Add64Wrap dst src = | false | null | false | (mk_ins (make_instr (I.ins_Add64) dst src)) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.out",
"Vale.X64.Instruction_s.opFlagsCf",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.op64",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.HavocFlags",
"Vale.X64.Instructions_s.ins_Add64",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Add64Wrap : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code | [] | Vale.X64.InsBasic.va_code_Add64Wrap | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64
-> Vale.X64.Decls.va_code | {
"end_col": 45,
"end_line": 106,
"start_col": 2,
"start_line": 106
} |
Prims.Tot | val va_code_Mov64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) | val va_code_Mov64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code
let va_code_Mov64 dst src = | false | null | false | (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr_annotate",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.out",
"Vale.X64.Instruction_s.op64",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Mov64",
"Vale.X64.Machine_Semantics_s.AnnotateMov64",
"Vale.X64.Instruction_s.InstrTypeRecord",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Mov64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code | [] | Vale.X64.InsBasic.va_code_Mov64 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64
-> Vale.X64.Decls.va_code | {
"end_col": 75,
"end_line": 17,
"start_col": 2,
"start_line": 17
} |
Prims.Tot | val va_code_Cmovc64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src)) | val va_code_Cmovc64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code
let va_code_Cmovc64 dst src = | false | null | false | (mk_ins (make_instr (I.ins_Cmovc64) dst src)) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.op64",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.opFlagsCf",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Cmovc64",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Cmovc64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code | [] | Vale.X64.InsBasic.va_code_Cmovc64 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64
-> Vale.X64.Decls.va_code | {
"end_col": 47,
"end_line": 47,
"start_col": 2,
"start_line": 47
} |
Prims.Tot | val va_code_And64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src)) | val va_code_And64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code
let va_code_And64 dst src = | false | null | false | (mk_ins (make_instr (I.ins_And64) dst src)) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.op64",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.HavocFlags",
"Vale.X64.Instructions_s.ins_And64",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_And64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code | [] | Vale.X64.InsBasic.va_code_And64 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64
-> Vale.X64.Decls.va_code | {
"end_col": 45,
"end_line": 519,
"start_col": 2,
"start_line": 519
} |
Prims.Tot | val va_code_Sub64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src)) | val va_code_Sub64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code
let va_code_Sub64 dst src = | false | null | false | (mk_ins (make_instr (I.ins_Sub64) dst src)) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.out",
"Vale.X64.Instruction_s.opFlagsCf",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.op64",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.HavocFlags",
"Vale.X64.Instructions_s.ins_Sub64",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Sub64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code | [] | Vale.X64.InsBasic.va_code_Sub64 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64
-> Vale.X64.Decls.va_code | {
"end_col": 45,
"end_line": 291,
"start_col": 2,
"start_line": 291
} |
Prims.Tot | val va_code_Shl64 : dst:va_operand_dst_opr64 -> amt:va_operand_shift_amt64 -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt)) | val va_code_Shl64 : dst:va_operand_dst_opr64 -> amt:va_operand_shift_amt64 -> Tot va_code
let va_code_Shl64 dst amt = | false | null | false | (mk_ins (make_instr (I.ins_Shl64) dst amt)) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_shift_amt64",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.op64",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.HavocFlags",
"Vale.X64.Instructions_s.ins_Shl64",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Shl64 : dst:va_operand_dst_opr64 -> amt:va_operand_shift_amt64 -> Tot va_code | [] | Vale.X64.InsBasic.va_code_Shl64 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dst: Vale.X64.Decls.va_operand_dst_opr64 -> amt: Vale.X64.Decls.va_operand_shift_amt64
-> Vale.X64.Decls.va_code | {
"end_col": 45,
"end_line": 549,
"start_col": 2,
"start_line": 549
} |
Prims.Tot | val va_codegen_success_Mulx64 : dst_hi:va_operand_dst_opr64 -> dst_lo:va_operand_dst_opr64 ->
src:va_operand_opr64 -> Tot va_pbool | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ()) | val va_codegen_success_Mulx64 : dst_hi:va_operand_dst_opr64 -> dst_lo:va_operand_dst_opr64 ->
src:va_operand_opr64 -> Tot va_pbool
let va_codegen_success_Mulx64 dst_hi dst_lo src = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Decls.va_ttrue",
"Vale.X64.Decls.va_pbool"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_Mulx64 : dst_hi:va_operand_dst_opr64 -> dst_lo:va_operand_dst_opr64 ->
src:va_operand_opr64 -> Tot va_pbool | [] | Vale.X64.InsBasic.va_codegen_success_Mulx64 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst_hi: Vale.X64.Decls.va_operand_dst_opr64 ->
dst_lo: Vale.X64.Decls.va_operand_dst_opr64 ->
src: Vale.X64.Decls.va_operand_opr64
-> Vale.X64.Decls.va_pbool | {
"end_col": 15,
"end_line": 425,
"start_col": 2,
"start_line": 425
} |
Prims.Tot | val va_code_Cpuid_Sha : va_dummy:unit -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid))) | val va_code_Cpuid_Sha : va_dummy:unit -> Tot va_code
let va_code_Cpuid_Sha () = | false | null | false | (mk_ins (make_instr (I.ins_Cpuid))) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.one64Reg",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Instruction_s.out",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRdx",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Cpuid",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Cpuid_Sha : va_dummy:unit -> Tot va_code | [] | Vale.X64.InsBasic.va_code_Cpuid_Sha | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.X64.Decls.va_code | {
"end_col": 37,
"end_line": 641,
"start_col": 2,
"start_line": 641
} |
Prims.Tot | val va_codegen_success_Cpuid_Sha : va_dummy:unit -> Tot va_pbool | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_codegen_success_Cpuid_Sha () =
(va_ttrue ()) | val va_codegen_success_Cpuid_Sha : va_dummy:unit -> Tot va_pbool
let va_codegen_success_Cpuid_Sha () = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.X64.Decls.va_ttrue",
"Vale.X64.Decls.va_pbool"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_Cpuid_Sha : va_dummy:unit -> Tot va_pbool | [] | Vale.X64.InsBasic.va_codegen_success_Cpuid_Sha | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.X64.Decls.va_pbool | {
"end_col": 15,
"end_line": 645,
"start_col": 2,
"start_line": 645
} |
Prims.Tot | val va_codegen_success_Cpuid_Avx2 : va_dummy:unit -> Tot va_pbool | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ()) | val va_codegen_success_Cpuid_Avx2 : va_dummy:unit -> Tot va_pbool
let va_codegen_success_Cpuid_Avx2 () = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.X64.Decls.va_ttrue",
"Vale.X64.Decls.va_pbool"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_Cpuid_Avx2 : va_dummy:unit -> Tot va_pbool | [] | Vale.X64.InsBasic.va_codegen_success_Cpuid_Avx2 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.X64.Decls.va_pbool | {
"end_col": 15,
"end_line": 741,
"start_col": 2,
"start_line": 741
} |
Prims.Tot | val va_codegen_success_And64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_codegen_success_And64 dst src =
(va_ttrue ()) | val va_codegen_success_And64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool
let va_codegen_success_And64 dst src = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Decls.va_ttrue",
"Vale.X64.Decls.va_pbool"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_And64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool | [] | Vale.X64.InsBasic.va_codegen_success_And64 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64
-> Vale.X64.Decls.va_pbool | {
"end_col": 15,
"end_line": 523,
"start_col": 2,
"start_line": 523
} |
Prims.Tot | val va_code_Shr64 : dst:va_operand_dst_opr64 -> amt:va_operand_shift_amt64 -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt)) | val va_code_Shr64 : dst:va_operand_dst_opr64 -> amt:va_operand_shift_amt64 -> Tot va_code
let va_code_Shr64 dst amt = | false | null | false | (mk_ins (make_instr (I.ins_Shr64) dst amt)) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_shift_amt64",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.op64",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.HavocFlags",
"Vale.X64.Instructions_s.ins_Shr64",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Shr64 : dst:va_operand_dst_opr64 -> amt:va_operand_shift_amt64 -> Tot va_code | [] | Vale.X64.InsBasic.va_code_Shr64 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dst: Vale.X64.Decls.va_operand_dst_opr64 -> amt: Vale.X64.Decls.va_operand_shift_amt64
-> Vale.X64.Decls.va_code | {
"end_col": 45,
"end_line": 579,
"start_col": 2,
"start_line": 579
} |
Prims.Tot | val va_codegen_success_Cpuid_Avx : va_dummy:unit -> Tot va_pbool | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_codegen_success_Cpuid_Avx () =
(va_ttrue ()) | val va_codegen_success_Cpuid_Avx : va_dummy:unit -> Tot va_pbool
let va_codegen_success_Cpuid_Avx () = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.X64.Decls.va_ttrue",
"Vale.X64.Decls.va_pbool"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_Cpuid_Avx : va_dummy:unit -> Tot va_pbool | [] | Vale.X64.InsBasic.va_codegen_success_Cpuid_Avx | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.X64.Decls.va_pbool | {
"end_col": 15,
"end_line": 709,
"start_col": 2,
"start_line": 709
} |
Prims.Tot | val va_code_Cpuid_Avx512 : va_dummy:unit -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid))) | val va_code_Cpuid_Avx512 : va_dummy:unit -> Tot va_code
let va_code_Cpuid_Avx512 () = | false | null | false | (mk_ins (make_instr (I.ins_Cpuid))) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.one64Reg",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Instruction_s.out",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRdx",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Cpuid",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Cpuid_Avx512 : va_dummy:unit -> Tot va_code | [] | Vale.X64.InsBasic.va_code_Cpuid_Avx512 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.X64.Decls.va_code | {
"end_col": 37,
"end_line": 865,
"start_col": 2,
"start_line": 865
} |
Prims.Tot | val va_code_Xgetbv_Avx512 : va_dummy:unit -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv))) | val va_code_Xgetbv_Avx512 : va_dummy:unit -> Tot va_code
let va_code_Xgetbv_Avx512 () = | false | null | false | (mk_ins (make_instr (I.ins_Xgetbv))) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.out",
"Vale.X64.Instruction_s.one64Reg",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Machine_s.rRdx",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Xgetbv",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Xgetbv_Avx512 : va_dummy:unit -> Tot va_code | [] | Vale.X64.InsBasic.va_code_Xgetbv_Avx512 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.X64.Decls.va_code | {
"end_col": 38,
"end_line": 960,
"start_col": 2,
"start_line": 960
} |
Prims.Tot | val va_code_Cpuid_Osxsave : va_dummy:unit -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid))) | val va_code_Cpuid_Osxsave : va_dummy:unit -> Tot va_code
let va_code_Cpuid_Osxsave () = | false | null | false | (mk_ins (make_instr (I.ins_Cpuid))) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.one64Reg",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Instruction_s.out",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRdx",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Cpuid",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Cpuid_Osxsave : va_dummy:unit -> Tot va_code | [] | Vale.X64.InsBasic.va_code_Cpuid_Osxsave | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.X64.Decls.va_code | {
"end_col": 37,
"end_line": 897,
"start_col": 2,
"start_line": 897
} |
Prims.Tot | val va_code_Comment : c:string -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Comment c =
(mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) | val va_code_Comment : c:string -> Tot va_code
let va_code_Comment c = | false | null | false | (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Prims.string",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr_annotate",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Comment",
"Vale.X64.Machine_Semantics_s.AnnotateComment",
"Vale.X64.Instruction_s.InstrTypeRecord",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"]
let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ())))))
[@ "opaque_to_smt"]
let va_codegen_success_Nat64Equal dst src =
(va_pbool_and (va_codegen_success_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Mov64
(va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_pbool_and
(va_codegen_success_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_ttrue
()))))
[@"opaque_to_smt"]
let va_lemma_Nat64Equal va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
let (va_s2, va_fc2) = va_lemma_Sub64Wrap (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64
src) (va_const_opr64 18446744073709551615) in
let va_b2 = va_tl va_b1 in
let (va_s3, va_fc3) = va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b3 = va_tl va_b2 in
let (va_s4, va_fc4) = va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b4 = va_tl va_b3 in
let (va_sM, va_f4) = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Nat64Equal dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Nat64Equal (va_code_Nat64Equal dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_reg_opr64
src va_sM (va_update_operand_reg_opr64 dst va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_reg_opr64 src; va_mod_reg_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Comment
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Comment : c:string -> Tot va_code | [] | Vale.X64.InsBasic.va_code_Comment | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | c: Prims.string -> Vale.X64.Decls.va_code | {
"end_col": 72,
"end_line": 1040,
"start_col": 2,
"start_line": 1040
} |
Prims.Tot | val va_code_Newline : va_dummy:unit -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Newline () =
(mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ()))) | val va_code_Newline : va_dummy:unit -> Tot va_code
let va_code_Newline () = | false | null | false | (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ()))) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr_annotate",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Newline",
"Vale.X64.Machine_Semantics_s.AnnotateNewline",
"Vale.X64.Instruction_s.InstrTypeRecord",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"]
let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ())))))
[@ "opaque_to_smt"]
let va_codegen_success_Nat64Equal dst src =
(va_pbool_and (va_codegen_success_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Mov64
(va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_pbool_and
(va_codegen_success_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_ttrue
()))))
[@"opaque_to_smt"]
let va_lemma_Nat64Equal va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
let (va_s2, va_fc2) = va_lemma_Sub64Wrap (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64
src) (va_const_opr64 18446744073709551615) in
let va_b2 = va_tl va_b1 in
let (va_s3, va_fc3) = va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b3 = va_tl va_b2 in
let (va_s4, va_fc4) = va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b4 = va_tl va_b3 in
let (va_sM, va_f4) = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Nat64Equal dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Nat64Equal (va_code_Nat64Equal dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_reg_opr64
src va_sM (va_update_operand_reg_opr64 dst va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_reg_opr64 src; va_mod_reg_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Comment
[@ "opaque_to_smt"]
let va_code_Comment c =
(mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_Comment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Comment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_Comment) (va_code_Comment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Comment c)
(S.AnnotateComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Comment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Comment (va_code_Comment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- LargeComment
[@ "opaque_to_smt"]
let va_code_LargeComment c =
(mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_LargeComment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_LargeComment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_LargeComment) (va_code_LargeComment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_LargeComment c)
(S.AnnotateLargeComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_LargeComment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_LargeComment (va_code_LargeComment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- NoNewline
[@ "opaque_to_smt"]
let va_code_NoNewline () =
(mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0)))
[@ "opaque_to_smt"]
let va_codegen_success_NoNewline () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_NoNewline va_b0 va_s0 =
va_reveal_opaque (`%va_code_NoNewline) (va_code_NoNewline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace
0))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_NoNewline va_s0 va_k =
let (va_sM, va_f0) = va_lemma_NoNewline (va_code_NoNewline ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Newline
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Newline : va_dummy:unit -> Tot va_code | [] | Vale.X64.InsBasic.va_code_Newline | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.X64.Decls.va_code | {
"end_col": 71,
"end_line": 1131,
"start_col": 2,
"start_line": 1131
} |
Prims.Tot | val va_code_Xgetbv_Avx : va_dummy:unit -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv))) | val va_code_Xgetbv_Avx : va_dummy:unit -> Tot va_code
let va_code_Xgetbv_Avx () = | false | null | false | (mk_ins (make_instr (I.ins_Xgetbv))) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.out",
"Vale.X64.Instruction_s.one64Reg",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Machine_s.rRdx",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Xgetbv",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Xgetbv_Avx : va_dummy:unit -> Tot va_code | [] | Vale.X64.InsBasic.va_code_Xgetbv_Avx | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.X64.Decls.va_code | {
"end_col": 38,
"end_line": 929,
"start_col": 2,
"start_line": 929
} |
Prims.Tot | val va_code_Nat64Equal : dst:va_operand_reg_opr64 -> src:va_operand_reg_opr64 -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ()))))) | val va_code_Nat64Equal : dst:va_operand_reg_opr64 -> src:va_operand_reg_opr64 -> Tot va_code
let va_code_Nat64Equal dst src = | false | null | false | (va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615))
(va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0))
(va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0))
(va_CNil ()))))) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_reg_opr64",
"Vale.X64.Decls.va_Block",
"Vale.X64.Decls.va_CCons",
"Vale.X64.InsBasic.va_code_Sub64Wrap",
"Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64",
"Vale.X64.Decls.va_const_opr64",
"Vale.X64.InsBasic.va_code_Mov64",
"Vale.X64.InsBasic.va_code_Adc64",
"Vale.X64.Decls.va_CNil",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Nat64Equal : dst:va_operand_reg_opr64 -> src:va_operand_reg_opr64 -> Tot va_code | [] | Vale.X64.InsBasic.va_code_Nat64Equal | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dst: Vale.X64.Decls.va_operand_reg_opr64 -> src: Vale.X64.Decls.va_operand_reg_opr64
-> Vale.X64.Decls.va_code | {
"end_col": 40,
"end_line": 994,
"start_col": 2,
"start_line": 991
} |
Prims.Tot | val va_code_Cpuid_Movbe : va_dummy:unit -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid))) | val va_code_Cpuid_Movbe : va_dummy:unit -> Tot va_code
let va_code_Cpuid_Movbe () = | false | null | false | (mk_ins (make_instr (I.ins_Cpuid))) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.one64Reg",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Instruction_s.out",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRdx",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Cpuid",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Cpuid_Movbe : va_dummy:unit -> Tot va_code | [] | Vale.X64.InsBasic.va_code_Cpuid_Movbe | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.X64.Decls.va_code | {
"end_col": 37,
"end_line": 801,
"start_col": 2,
"start_line": 801
} |
Prims.Tot | val va_codegen_success_Newline : va_dummy:unit -> Tot va_pbool | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_codegen_success_Newline () =
(va_ttrue ()) | val va_codegen_success_Newline : va_dummy:unit -> Tot va_pbool
let va_codegen_success_Newline () = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.X64.Decls.va_ttrue",
"Vale.X64.Decls.va_pbool"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"]
let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ())))))
[@ "opaque_to_smt"]
let va_codegen_success_Nat64Equal dst src =
(va_pbool_and (va_codegen_success_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Mov64
(va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_pbool_and
(va_codegen_success_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_ttrue
()))))
[@"opaque_to_smt"]
let va_lemma_Nat64Equal va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
let (va_s2, va_fc2) = va_lemma_Sub64Wrap (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64
src) (va_const_opr64 18446744073709551615) in
let va_b2 = va_tl va_b1 in
let (va_s3, va_fc3) = va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b3 = va_tl va_b2 in
let (va_s4, va_fc4) = va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b4 = va_tl va_b3 in
let (va_sM, va_f4) = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Nat64Equal dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Nat64Equal (va_code_Nat64Equal dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_reg_opr64
src va_sM (va_update_operand_reg_opr64 dst va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_reg_opr64 src; va_mod_reg_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Comment
[@ "opaque_to_smt"]
let va_code_Comment c =
(mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_Comment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Comment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_Comment) (va_code_Comment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Comment c)
(S.AnnotateComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Comment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Comment (va_code_Comment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- LargeComment
[@ "opaque_to_smt"]
let va_code_LargeComment c =
(mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_LargeComment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_LargeComment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_LargeComment) (va_code_LargeComment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_LargeComment c)
(S.AnnotateLargeComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_LargeComment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_LargeComment (va_code_LargeComment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- NoNewline
[@ "opaque_to_smt"]
let va_code_NoNewline () =
(mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0)))
[@ "opaque_to_smt"]
let va_codegen_success_NoNewline () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_NoNewline va_b0 va_s0 =
va_reveal_opaque (`%va_code_NoNewline) (va_code_NoNewline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace
0))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_NoNewline va_s0 va_k =
let (va_sM, va_f0) = va_lemma_NoNewline (va_code_NoNewline ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Newline
[@ "opaque_to_smt"]
let va_code_Newline () =
(mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ())))
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_Newline : va_dummy:unit -> Tot va_pbool | [] | Vale.X64.InsBasic.va_codegen_success_Newline | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.X64.Decls.va_pbool | {
"end_col": 15,
"end_line": 1135,
"start_col": 2,
"start_line": 1135
} |
Prims.Tot | val va_code_Prefetchnta : v:va_operand_opr64 -> Tot va_code | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Prefetchnta v =
(mk_ins (make_instr_annotate (I.ins_Prefetchnta) (S.AnnotatePrefetchnta ()) v)) | val va_code_Prefetchnta : v:va_operand_opr64 -> Tot va_code
let va_code_Prefetchnta v = | false | null | false | (mk_ins (make_instr_annotate (I.ins_Prefetchnta) (S.AnnotatePrefetchnta ()) v)) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr_annotate",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_out",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.op64",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Prefetchnta",
"Vale.X64.Machine_Semantics_s.AnnotatePrefetchnta",
"Vale.X64.Instruction_s.InstrTypeRecord",
"Vale.X64.Decls.va_code"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"]
let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ())))))
[@ "opaque_to_smt"]
let va_codegen_success_Nat64Equal dst src =
(va_pbool_and (va_codegen_success_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Mov64
(va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_pbool_and
(va_codegen_success_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_ttrue
()))))
[@"opaque_to_smt"]
let va_lemma_Nat64Equal va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
let (va_s2, va_fc2) = va_lemma_Sub64Wrap (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64
src) (va_const_opr64 18446744073709551615) in
let va_b2 = va_tl va_b1 in
let (va_s3, va_fc3) = va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b3 = va_tl va_b2 in
let (va_s4, va_fc4) = va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b4 = va_tl va_b3 in
let (va_sM, va_f4) = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Nat64Equal dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Nat64Equal (va_code_Nat64Equal dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_reg_opr64
src va_sM (va_update_operand_reg_opr64 dst va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_reg_opr64 src; va_mod_reg_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Comment
[@ "opaque_to_smt"]
let va_code_Comment c =
(mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_Comment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Comment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_Comment) (va_code_Comment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Comment c)
(S.AnnotateComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Comment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Comment (va_code_Comment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- LargeComment
[@ "opaque_to_smt"]
let va_code_LargeComment c =
(mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_LargeComment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_LargeComment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_LargeComment) (va_code_LargeComment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_LargeComment c)
(S.AnnotateLargeComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_LargeComment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_LargeComment (va_code_LargeComment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- NoNewline
[@ "opaque_to_smt"]
let va_code_NoNewline () =
(mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0)))
[@ "opaque_to_smt"]
let va_codegen_success_NoNewline () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_NoNewline va_b0 va_s0 =
va_reveal_opaque (`%va_code_NoNewline) (va_code_NoNewline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace
0))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_NoNewline va_s0 va_k =
let (va_sM, va_f0) = va_lemma_NoNewline (va_code_NoNewline ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Newline
[@ "opaque_to_smt"]
let va_code_Newline () =
(mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ())))
[@ "opaque_to_smt"]
let va_codegen_success_Newline () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Newline va_b0 va_s0 =
va_reveal_opaque (`%va_code_Newline) (va_code_Newline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ()))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline
()))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Newline va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Newline (va_code_Newline ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Space
[@ "opaque_to_smt"]
let va_code_Space n =
(mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace n)))
[@ "opaque_to_smt"]
let va_codegen_success_Space n =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Space va_b0 va_s0 n =
va_reveal_opaque (`%va_code_Space) (va_code_Space n);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace n))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace
n))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Space n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Space (va_code_Space n) va_s0 n in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Prefetchnta
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Prefetchnta : v:va_operand_opr64 -> Tot va_code | [] | Vale.X64.InsBasic.va_code_Prefetchnta | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | v: Vale.X64.Decls.va_operand_opr64 -> Vale.X64.Decls.va_code | {
"end_col": 81,
"end_line": 1191,
"start_col": 2,
"start_line": 1191
} |
Prims.Tot | val va_codegen_success_Mov64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_codegen_success_Mov64 dst src =
(va_ttrue ()) | val va_codegen_success_Mov64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool
let va_codegen_success_Mov64 dst src = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Decls.va_ttrue",
"Vale.X64.Decls.va_pbool"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_Mov64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool | [] | Vale.X64.InsBasic.va_codegen_success_Mov64 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64
-> Vale.X64.Decls.va_pbool | {
"end_col": 15,
"end_line": 21,
"start_col": 2,
"start_line": 21
} |
Subsets and Splits