file_name
stringlengths 5
52
| name
stringlengths 4
95
| original_source_type
stringlengths 0
23k
| source_type
stringlengths 9
23k
| source_definition
stringlengths 9
57.9k
| source
dict | source_range
dict | file_context
stringlengths 0
721k
| dependencies
dict | opens_and_abbrevs
listlengths 2
94
| vconfig
dict | interleaved
bool 1
class | verbose_type
stringlengths 1
7.42k
| effect
stringclasses 118
values | effect_flags
sequencelengths 0
2
| mutual_with
sequencelengths 0
11
| ideal_premises
sequencelengths 0
236
| proof_features
sequencelengths 0
1
| is_simple_lemma
bool 2
classes | is_div
bool 2
classes | is_proof
bool 2
classes | is_simply_typed
bool 2
classes | is_type
bool 2
classes | partial_definition
stringlengths 5
3.99k
| completed_definiton
stringlengths 1
1.63M
| isa_cross_project_example
bool 1
class |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Steel.Effect.Common.fst | Steel.Effect.Common.star_congruence | val star_congruence (p1 p2 p3 p4:vprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4)) | val star_congruence (p1 p2 p3 p4:vprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4)) | let star_congruence p1 p2 p3 p4 = Mem.star_congruence (hp_of p1) (hp_of p2) (hp_of p3) (hp_of p4) | {
"file_name": "lib/steel/Steel.Effect.Common.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 97,
"end_line": 112,
"start_col": 0,
"start_line": 112
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Effect.Common
module Sem = Steel.Semantics.Hoare.MST
module Mem = Steel.Memory
open Steel.Semantics.Instantiate
module FExt = FStar.FunctionalExtensionality
let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()})
let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q)
let reveal_can_be_split () = ()
let can_be_split_interp r r' h = ()
let can_be_split_trans p q r = ()
let can_be_split_star_l p q = ()
let can_be_split_star_r p q = ()
let can_be_split_refl p = ()
let can_be_split_congr_l p q r =
Classical.forall_intro (interp_star (hp_of p) (hp_of r));
Classical.forall_intro (interp_star (hp_of q) (hp_of r))
let can_be_split_congr_r p q r =
Classical.forall_intro (interp_star (hp_of r) (hp_of p));
Classical.forall_intro (interp_star (hp_of r) (hp_of q))
let equiv (p q:vprop) : prop = Mem.equiv (hp_of p) (hp_of q) /\ True
let reveal_equiv p q = ()
let valid_rmem (#frame:vprop) (h:rmem' frame) : prop =
forall (p p1 p2:vprop). can_be_split frame p /\ p == VStar p1 p2 ==>
(h p1, h p2) == h (VStar p1 p2)
let lemma_valid_mk_rmem (r:vprop) (h:hmem r) = ()
let reveal_mk_rmem (r:vprop) (h:hmem r) (r0:vprop{r `can_be_split` r0})
: Lemma ((mk_rmem r h) r0 == sel_of r0 h)
= FExt.feq_on_domain_g (unrestricted_mk_rmem r h)
let emp':vprop' =
{ hp = emp;
t = unit;
sel = fun _ -> ()}
let emp = VUnit emp'
let reveal_emp () = ()
let lemma_valid_focus_rmem #r h r0 =
Classical.forall_intro (Classical.move_requires (can_be_split_trans r r0))
let rec lemma_frame_refl' (frame:vprop) (h0:rmem frame) (h1:rmem frame)
: Lemma ((h0 frame == h1 frame) <==> frame_equalities' frame h0 h1)
= match frame with
| VUnit _ -> ()
| VStar p1 p2 ->
can_be_split_star_l p1 p2;
can_be_split_star_r p1 p2;
let h01 : rmem p1 = focus_rmem h0 p1 in
let h11 : rmem p1 = focus_rmem h1 p1 in
let h02 = focus_rmem h0 p2 in
let h12 = focus_rmem h1 p2 in
lemma_frame_refl' p1 h01 h11;
lemma_frame_refl' p2 h02 h12
let lemma_frame_equalities frame h0 h1 p =
let p1 : prop = h0 frame == h1 frame in
let p2 : prop = frame_equalities' frame h0 h1 in
lemma_frame_refl' frame h0 h1;
FStar.PropositionalExtensionality.apply p1 p2
let lemma_frame_emp h0 h1 p =
FStar.PropositionalExtensionality.apply True (h0 (VUnit emp') == h1 (VUnit emp'))
let elim_conjunction p1 p1' p2 p2' = ()
let can_be_split_dep_refl p = ()
let equiv_can_be_split p1 p2 = ()
let intro_can_be_split_frame p q frame = ()
let can_be_split_post_elim t1 t2 = ()
let equiv_forall_refl t = ()
let equiv_forall_elim t1 t2 = ()
let equiv_refl x = ()
let equiv_sym x y = ()
let equiv_trans x y z = ()
let cm_identity x =
Mem.emp_unit (hp_of x);
Mem.star_commutative (hp_of x) Mem.emp
let star_commutative p1 p2 = Mem.star_commutative (hp_of p1) (hp_of p2) | {
"checked_file": "/",
"dependencies": [
"Steel.Semantics.Instantiate.fsti.checked",
"Steel.Semantics.Hoare.MST.fst.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.PropositionalExtensionality.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.Effect.Common.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommMonoidSimple.Equiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": false,
"full_module": "Steel.Semantics.Instantiate",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "Steel.Semantics.Hoare.MST",
"short_module": "Sem"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p1: Steel.Effect.Common.vprop ->
p2: Steel.Effect.Common.vprop ->
p3: Steel.Effect.Common.vprop ->
p4: Steel.Effect.Common.vprop
-> FStar.Pervasives.Lemma
(requires Steel.Effect.Common.equiv p1 p3 /\ Steel.Effect.Common.equiv p2 p4)
(ensures
Steel.Effect.Common.equiv (Steel.Effect.Common.star p1 p2) (Steel.Effect.Common.star p3 p4)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Memory.star_congruence",
"Steel.Effect.Common.hp_of",
"Prims.unit"
] | [] | true | false | true | false | false | let star_congruence p1 p2 p3 p4 =
| Mem.star_congruence (hp_of p1) (hp_of p2) (hp_of p3) (hp_of p4) | false |
Steel.Effect.Common.fst | Steel.Effect.Common.vrefine_sel | val vrefine_sel (v: vprop) (p: (normal (t_of v) -> Tot prop)) : Tot (selector (vrefine_t v p) (vrefine_hp v p)) | val vrefine_sel (v: vprop) (p: (normal (t_of v) -> Tot prop)) : Tot (selector (vrefine_t v p) (vrefine_hp v p)) | let vrefine_sel
v p
= assert (sel_depends_only_on (vrefine_sel' v p));
assert (sel_depends_only_on_core (vrefine_sel' v p));
vrefine_sel' v p | {
"file_name": "lib/steel/Steel.Effect.Common.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 18,
"end_line": 135,
"start_col": 0,
"start_line": 131
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Effect.Common
module Sem = Steel.Semantics.Hoare.MST
module Mem = Steel.Memory
open Steel.Semantics.Instantiate
module FExt = FStar.FunctionalExtensionality
let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()})
let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q)
let reveal_can_be_split () = ()
let can_be_split_interp r r' h = ()
let can_be_split_trans p q r = ()
let can_be_split_star_l p q = ()
let can_be_split_star_r p q = ()
let can_be_split_refl p = ()
let can_be_split_congr_l p q r =
Classical.forall_intro (interp_star (hp_of p) (hp_of r));
Classical.forall_intro (interp_star (hp_of q) (hp_of r))
let can_be_split_congr_r p q r =
Classical.forall_intro (interp_star (hp_of r) (hp_of p));
Classical.forall_intro (interp_star (hp_of r) (hp_of q))
let equiv (p q:vprop) : prop = Mem.equiv (hp_of p) (hp_of q) /\ True
let reveal_equiv p q = ()
let valid_rmem (#frame:vprop) (h:rmem' frame) : prop =
forall (p p1 p2:vprop). can_be_split frame p /\ p == VStar p1 p2 ==>
(h p1, h p2) == h (VStar p1 p2)
let lemma_valid_mk_rmem (r:vprop) (h:hmem r) = ()
let reveal_mk_rmem (r:vprop) (h:hmem r) (r0:vprop{r `can_be_split` r0})
: Lemma ((mk_rmem r h) r0 == sel_of r0 h)
= FExt.feq_on_domain_g (unrestricted_mk_rmem r h)
let emp':vprop' =
{ hp = emp;
t = unit;
sel = fun _ -> ()}
let emp = VUnit emp'
let reveal_emp () = ()
let lemma_valid_focus_rmem #r h r0 =
Classical.forall_intro (Classical.move_requires (can_be_split_trans r r0))
let rec lemma_frame_refl' (frame:vprop) (h0:rmem frame) (h1:rmem frame)
: Lemma ((h0 frame == h1 frame) <==> frame_equalities' frame h0 h1)
= match frame with
| VUnit _ -> ()
| VStar p1 p2 ->
can_be_split_star_l p1 p2;
can_be_split_star_r p1 p2;
let h01 : rmem p1 = focus_rmem h0 p1 in
let h11 : rmem p1 = focus_rmem h1 p1 in
let h02 = focus_rmem h0 p2 in
let h12 = focus_rmem h1 p2 in
lemma_frame_refl' p1 h01 h11;
lemma_frame_refl' p2 h02 h12
let lemma_frame_equalities frame h0 h1 p =
let p1 : prop = h0 frame == h1 frame in
let p2 : prop = frame_equalities' frame h0 h1 in
lemma_frame_refl' frame h0 h1;
FStar.PropositionalExtensionality.apply p1 p2
let lemma_frame_emp h0 h1 p =
FStar.PropositionalExtensionality.apply True (h0 (VUnit emp') == h1 (VUnit emp'))
let elim_conjunction p1 p1' p2 p2' = ()
let can_be_split_dep_refl p = ()
let equiv_can_be_split p1 p2 = ()
let intro_can_be_split_frame p q frame = ()
let can_be_split_post_elim t1 t2 = ()
let equiv_forall_refl t = ()
let equiv_forall_elim t1 t2 = ()
let equiv_refl x = ()
let equiv_sym x y = ()
let equiv_trans x y z = ()
let cm_identity x =
Mem.emp_unit (hp_of x);
Mem.star_commutative (hp_of x) Mem.emp
let star_commutative p1 p2 = Mem.star_commutative (hp_of p1) (hp_of p2)
let star_associative p1 p2 p3 = Mem.star_associative (hp_of p1) (hp_of p2) (hp_of p3)
let star_congruence p1 p2 p3 p4 = Mem.star_congruence (hp_of p1) (hp_of p2) (hp_of p3) (hp_of p4)
let vrefine_am (v: vprop) (p: (t_of v -> Tot prop)) : Tot (a_mem_prop (hp_of v)) =
fun h -> p (sel_of v h)
let vrefine_hp
v p
= refine_slprop (hp_of v) (vrefine_am v p)
let interp_vrefine_hp
v p m
= ()
let vrefine_sel' (v: vprop) (p: (t_of v -> Tot prop)) : Tot (selector' (vrefine_t v p) (vrefine_hp v p))
=
fun (h: Mem.hmem (vrefine_hp v p)) ->
interp_refine_slprop (hp_of v) (vrefine_am v p) h;
sel_of v h | {
"checked_file": "/",
"dependencies": [
"Steel.Semantics.Instantiate.fsti.checked",
"Steel.Semantics.Hoare.MST.fst.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.PropositionalExtensionality.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.Effect.Common.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommMonoidSimple.Equiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": false,
"full_module": "Steel.Semantics.Instantiate",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "Steel.Semantics.Hoare.MST",
"short_module": "Sem"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
v: Steel.Effect.Common.vprop ->
p: (_: Steel.Effect.Common.normal (Steel.Effect.Common.t_of v) -> Prims.prop)
-> Steel.Effect.Common.selector (Steel.Effect.Common.vrefine_t v p)
(Steel.Effect.Common.vrefine_hp v p) | Prims.Tot | [
"total"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.normal",
"Steel.Effect.Common.t_of",
"Prims.prop",
"Steel.Effect.Common.vrefine_sel'",
"Prims.unit",
"Prims._assert",
"Steel.Effect.Common.sel_depends_only_on_core",
"Steel.Effect.Common.vrefine_t",
"Steel.Effect.Common.vrefine_hp",
"Steel.Effect.Common.sel_depends_only_on",
"Steel.Effect.Common.selector"
] | [] | false | false | false | false | false | let vrefine_sel v p =
| assert (sel_depends_only_on (vrefine_sel' v p));
assert (sel_depends_only_on_core (vrefine_sel' v p));
vrefine_sel' v p | false |
Steel.Effect.Common.fst | Steel.Effect.Common.vrefine_hp | val vrefine_hp (v: vprop) (p: (normal (t_of v) -> Tot prop)) : Tot (slprop u#1) | val vrefine_hp (v: vprop) (p: (normal (t_of v) -> Tot prop)) : Tot (slprop u#1) | let vrefine_hp
v p
= refine_slprop (hp_of v) (vrefine_am v p) | {
"file_name": "lib/steel/Steel.Effect.Common.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 42,
"end_line": 119,
"start_col": 0,
"start_line": 117
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Effect.Common
module Sem = Steel.Semantics.Hoare.MST
module Mem = Steel.Memory
open Steel.Semantics.Instantiate
module FExt = FStar.FunctionalExtensionality
let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()})
let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q)
let reveal_can_be_split () = ()
let can_be_split_interp r r' h = ()
let can_be_split_trans p q r = ()
let can_be_split_star_l p q = ()
let can_be_split_star_r p q = ()
let can_be_split_refl p = ()
let can_be_split_congr_l p q r =
Classical.forall_intro (interp_star (hp_of p) (hp_of r));
Classical.forall_intro (interp_star (hp_of q) (hp_of r))
let can_be_split_congr_r p q r =
Classical.forall_intro (interp_star (hp_of r) (hp_of p));
Classical.forall_intro (interp_star (hp_of r) (hp_of q))
let equiv (p q:vprop) : prop = Mem.equiv (hp_of p) (hp_of q) /\ True
let reveal_equiv p q = ()
let valid_rmem (#frame:vprop) (h:rmem' frame) : prop =
forall (p p1 p2:vprop). can_be_split frame p /\ p == VStar p1 p2 ==>
(h p1, h p2) == h (VStar p1 p2)
let lemma_valid_mk_rmem (r:vprop) (h:hmem r) = ()
let reveal_mk_rmem (r:vprop) (h:hmem r) (r0:vprop{r `can_be_split` r0})
: Lemma ((mk_rmem r h) r0 == sel_of r0 h)
= FExt.feq_on_domain_g (unrestricted_mk_rmem r h)
let emp':vprop' =
{ hp = emp;
t = unit;
sel = fun _ -> ()}
let emp = VUnit emp'
let reveal_emp () = ()
let lemma_valid_focus_rmem #r h r0 =
Classical.forall_intro (Classical.move_requires (can_be_split_trans r r0))
let rec lemma_frame_refl' (frame:vprop) (h0:rmem frame) (h1:rmem frame)
: Lemma ((h0 frame == h1 frame) <==> frame_equalities' frame h0 h1)
= match frame with
| VUnit _ -> ()
| VStar p1 p2 ->
can_be_split_star_l p1 p2;
can_be_split_star_r p1 p2;
let h01 : rmem p1 = focus_rmem h0 p1 in
let h11 : rmem p1 = focus_rmem h1 p1 in
let h02 = focus_rmem h0 p2 in
let h12 = focus_rmem h1 p2 in
lemma_frame_refl' p1 h01 h11;
lemma_frame_refl' p2 h02 h12
let lemma_frame_equalities frame h0 h1 p =
let p1 : prop = h0 frame == h1 frame in
let p2 : prop = frame_equalities' frame h0 h1 in
lemma_frame_refl' frame h0 h1;
FStar.PropositionalExtensionality.apply p1 p2
let lemma_frame_emp h0 h1 p =
FStar.PropositionalExtensionality.apply True (h0 (VUnit emp') == h1 (VUnit emp'))
let elim_conjunction p1 p1' p2 p2' = ()
let can_be_split_dep_refl p = ()
let equiv_can_be_split p1 p2 = ()
let intro_can_be_split_frame p q frame = ()
let can_be_split_post_elim t1 t2 = ()
let equiv_forall_refl t = ()
let equiv_forall_elim t1 t2 = ()
let equiv_refl x = ()
let equiv_sym x y = ()
let equiv_trans x y z = ()
let cm_identity x =
Mem.emp_unit (hp_of x);
Mem.star_commutative (hp_of x) Mem.emp
let star_commutative p1 p2 = Mem.star_commutative (hp_of p1) (hp_of p2)
let star_associative p1 p2 p3 = Mem.star_associative (hp_of p1) (hp_of p2) (hp_of p3)
let star_congruence p1 p2 p3 p4 = Mem.star_congruence (hp_of p1) (hp_of p2) (hp_of p3) (hp_of p4)
let vrefine_am (v: vprop) (p: (t_of v -> Tot prop)) : Tot (a_mem_prop (hp_of v)) =
fun h -> p (sel_of v h) | {
"checked_file": "/",
"dependencies": [
"Steel.Semantics.Instantiate.fsti.checked",
"Steel.Semantics.Hoare.MST.fst.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.PropositionalExtensionality.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.Effect.Common.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommMonoidSimple.Equiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": false,
"full_module": "Steel.Semantics.Instantiate",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "Steel.Semantics.Hoare.MST",
"short_module": "Sem"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
v: Steel.Effect.Common.vprop ->
p: (_: Steel.Effect.Common.normal (Steel.Effect.Common.t_of v) -> Prims.prop)
-> Steel.Memory.slprop | Prims.Tot | [
"total"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.normal",
"Steel.Effect.Common.t_of",
"Prims.prop",
"Steel.Memory.refine_slprop",
"Steel.Effect.Common.hp_of",
"Steel.Effect.Common.vrefine_am",
"Steel.Memory.slprop"
] | [] | false | false | false | false | false | let vrefine_hp v p =
| refine_slprop (hp_of v) (vrefine_am v p) | false |
Steel.Effect.Common.fst | Steel.Effect.Common.vdep_sel' | val vdep_sel' (v: vprop) (p: (t_of v -> Tot vprop)) : Tot (selector' (vdep_t v p) (vdep_hp v p)) | val vdep_sel' (v: vprop) (p: (t_of v -> Tot vprop)) : Tot (selector' (vdep_t v p) (vdep_hp v p)) | let vdep_sel'
(v: vprop)
(p: t_of v -> Tot vprop)
: Tot (selector' (vdep_t v p) (vdep_hp v p))
=
fun (m: Mem.hmem (vdep_hp v p)) ->
interp_vdep_hp v p m;
let x = sel_of v m in
let y = sel_of (p (sel_of v m)) m in
(| x, y |) | {
"file_name": "lib/steel/Steel.Effect.Common.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 14,
"end_line": 183,
"start_col": 0,
"start_line": 174
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Effect.Common
module Sem = Steel.Semantics.Hoare.MST
module Mem = Steel.Memory
open Steel.Semantics.Instantiate
module FExt = FStar.FunctionalExtensionality
let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()})
let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q)
let reveal_can_be_split () = ()
let can_be_split_interp r r' h = ()
let can_be_split_trans p q r = ()
let can_be_split_star_l p q = ()
let can_be_split_star_r p q = ()
let can_be_split_refl p = ()
let can_be_split_congr_l p q r =
Classical.forall_intro (interp_star (hp_of p) (hp_of r));
Classical.forall_intro (interp_star (hp_of q) (hp_of r))
let can_be_split_congr_r p q r =
Classical.forall_intro (interp_star (hp_of r) (hp_of p));
Classical.forall_intro (interp_star (hp_of r) (hp_of q))
let equiv (p q:vprop) : prop = Mem.equiv (hp_of p) (hp_of q) /\ True
let reveal_equiv p q = ()
let valid_rmem (#frame:vprop) (h:rmem' frame) : prop =
forall (p p1 p2:vprop). can_be_split frame p /\ p == VStar p1 p2 ==>
(h p1, h p2) == h (VStar p1 p2)
let lemma_valid_mk_rmem (r:vprop) (h:hmem r) = ()
let reveal_mk_rmem (r:vprop) (h:hmem r) (r0:vprop{r `can_be_split` r0})
: Lemma ((mk_rmem r h) r0 == sel_of r0 h)
= FExt.feq_on_domain_g (unrestricted_mk_rmem r h)
let emp':vprop' =
{ hp = emp;
t = unit;
sel = fun _ -> ()}
let emp = VUnit emp'
let reveal_emp () = ()
let lemma_valid_focus_rmem #r h r0 =
Classical.forall_intro (Classical.move_requires (can_be_split_trans r r0))
let rec lemma_frame_refl' (frame:vprop) (h0:rmem frame) (h1:rmem frame)
: Lemma ((h0 frame == h1 frame) <==> frame_equalities' frame h0 h1)
= match frame with
| VUnit _ -> ()
| VStar p1 p2 ->
can_be_split_star_l p1 p2;
can_be_split_star_r p1 p2;
let h01 : rmem p1 = focus_rmem h0 p1 in
let h11 : rmem p1 = focus_rmem h1 p1 in
let h02 = focus_rmem h0 p2 in
let h12 = focus_rmem h1 p2 in
lemma_frame_refl' p1 h01 h11;
lemma_frame_refl' p2 h02 h12
let lemma_frame_equalities frame h0 h1 p =
let p1 : prop = h0 frame == h1 frame in
let p2 : prop = frame_equalities' frame h0 h1 in
lemma_frame_refl' frame h0 h1;
FStar.PropositionalExtensionality.apply p1 p2
let lemma_frame_emp h0 h1 p =
FStar.PropositionalExtensionality.apply True (h0 (VUnit emp') == h1 (VUnit emp'))
let elim_conjunction p1 p1' p2 p2' = ()
let can_be_split_dep_refl p = ()
let equiv_can_be_split p1 p2 = ()
let intro_can_be_split_frame p q frame = ()
let can_be_split_post_elim t1 t2 = ()
let equiv_forall_refl t = ()
let equiv_forall_elim t1 t2 = ()
let equiv_refl x = ()
let equiv_sym x y = ()
let equiv_trans x y z = ()
let cm_identity x =
Mem.emp_unit (hp_of x);
Mem.star_commutative (hp_of x) Mem.emp
let star_commutative p1 p2 = Mem.star_commutative (hp_of p1) (hp_of p2)
let star_associative p1 p2 p3 = Mem.star_associative (hp_of p1) (hp_of p2) (hp_of p3)
let star_congruence p1 p2 p3 p4 = Mem.star_congruence (hp_of p1) (hp_of p2) (hp_of p3) (hp_of p4)
let vrefine_am (v: vprop) (p: (t_of v -> Tot prop)) : Tot (a_mem_prop (hp_of v)) =
fun h -> p (sel_of v h)
let vrefine_hp
v p
= refine_slprop (hp_of v) (vrefine_am v p)
let interp_vrefine_hp
v p m
= ()
let vrefine_sel' (v: vprop) (p: (t_of v -> Tot prop)) : Tot (selector' (vrefine_t v p) (vrefine_hp v p))
=
fun (h: Mem.hmem (vrefine_hp v p)) ->
interp_refine_slprop (hp_of v) (vrefine_am v p) h;
sel_of v h
let vrefine_sel
v p
= assert (sel_depends_only_on (vrefine_sel' v p));
assert (sel_depends_only_on_core (vrefine_sel' v p));
vrefine_sel' v p
let vrefine_sel_eq
v p m
= ()
let vdep_hp_payload
(v: vprop)
(p: (t_of v -> Tot vprop))
(h: Mem.hmem (hp_of v))
: Tot slprop
= hp_of (p (sel_of v h))
let vdep_hp
v p
=
sdep (hp_of v) (vdep_hp_payload v p)
let interp_vdep_hp
v p m
=
interp_sdep (hp_of v) (vdep_hp_payload v p) m;
let left = interp (vdep_hp v p) m in
let right = interp (hp_of v) m /\ interp (hp_of v `Mem.star` hp_of (p (sel_of v m))) m in
let f ()
: Lemma
(requires left)
(ensures right)
= interp_star (hp_of v) (hp_of (p (sel_of v m))) m
in
let g ()
: Lemma
(requires right)
(ensures left)
= interp_star (hp_of v) (hp_of (p (sel_of v m))) m
in
Classical.move_requires f ();
Classical.move_requires g () | {
"checked_file": "/",
"dependencies": [
"Steel.Semantics.Instantiate.fsti.checked",
"Steel.Semantics.Hoare.MST.fst.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.PropositionalExtensionality.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.Effect.Common.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommMonoidSimple.Equiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": false,
"full_module": "Steel.Semantics.Instantiate",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "Steel.Semantics.Hoare.MST",
"short_module": "Sem"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | v: Steel.Effect.Common.vprop -> p: (_: Steel.Effect.Common.t_of v -> Steel.Effect.Common.vprop)
-> Steel.Effect.Common.selector' (Steel.Effect.Common.vdep_t v p)
(Steel.Effect.Common.vdep_hp v p) | Prims.Tot | [
"total"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.t_of",
"Steel.Memory.hmem",
"Steel.Effect.Common.vdep_hp",
"Prims.Mkdtuple2",
"Steel.Effect.Common.vdep_payload",
"Steel.Effect.Common.sel_of",
"Prims.unit",
"Steel.Effect.Common.interp_vdep_hp",
"Steel.Effect.Common.vdep_t",
"Steel.Effect.Common.selector'"
] | [] | false | false | false | false | false | let vdep_sel' (v: vprop) (p: (t_of v -> Tot vprop)) : Tot (selector' (vdep_t v p) (vdep_hp v p)) =
| fun (m: Mem.hmem (vdep_hp v p)) ->
interp_vdep_hp v p m;
let x = sel_of v m in
let y = sel_of (p (sel_of v m)) m in
(| x, y |) | false |
Steel.Effect.Common.fst | Steel.Effect.Common.cm_identity | val cm_identity (x:vprop) : Lemma ((emp `star` x) `equiv` x) | val cm_identity (x:vprop) : Lemma ((emp `star` x) `equiv` x) | let cm_identity x =
Mem.emp_unit (hp_of x);
Mem.star_commutative (hp_of x) Mem.emp | {
"file_name": "lib/steel/Steel.Effect.Common.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 40,
"end_line": 109,
"start_col": 0,
"start_line": 107
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Effect.Common
module Sem = Steel.Semantics.Hoare.MST
module Mem = Steel.Memory
open Steel.Semantics.Instantiate
module FExt = FStar.FunctionalExtensionality
let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()})
let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q)
let reveal_can_be_split () = ()
let can_be_split_interp r r' h = ()
let can_be_split_trans p q r = ()
let can_be_split_star_l p q = ()
let can_be_split_star_r p q = ()
let can_be_split_refl p = ()
let can_be_split_congr_l p q r =
Classical.forall_intro (interp_star (hp_of p) (hp_of r));
Classical.forall_intro (interp_star (hp_of q) (hp_of r))
let can_be_split_congr_r p q r =
Classical.forall_intro (interp_star (hp_of r) (hp_of p));
Classical.forall_intro (interp_star (hp_of r) (hp_of q))
let equiv (p q:vprop) : prop = Mem.equiv (hp_of p) (hp_of q) /\ True
let reveal_equiv p q = ()
let valid_rmem (#frame:vprop) (h:rmem' frame) : prop =
forall (p p1 p2:vprop). can_be_split frame p /\ p == VStar p1 p2 ==>
(h p1, h p2) == h (VStar p1 p2)
let lemma_valid_mk_rmem (r:vprop) (h:hmem r) = ()
let reveal_mk_rmem (r:vprop) (h:hmem r) (r0:vprop{r `can_be_split` r0})
: Lemma ((mk_rmem r h) r0 == sel_of r0 h)
= FExt.feq_on_domain_g (unrestricted_mk_rmem r h)
let emp':vprop' =
{ hp = emp;
t = unit;
sel = fun _ -> ()}
let emp = VUnit emp'
let reveal_emp () = ()
let lemma_valid_focus_rmem #r h r0 =
Classical.forall_intro (Classical.move_requires (can_be_split_trans r r0))
let rec lemma_frame_refl' (frame:vprop) (h0:rmem frame) (h1:rmem frame)
: Lemma ((h0 frame == h1 frame) <==> frame_equalities' frame h0 h1)
= match frame with
| VUnit _ -> ()
| VStar p1 p2 ->
can_be_split_star_l p1 p2;
can_be_split_star_r p1 p2;
let h01 : rmem p1 = focus_rmem h0 p1 in
let h11 : rmem p1 = focus_rmem h1 p1 in
let h02 = focus_rmem h0 p2 in
let h12 = focus_rmem h1 p2 in
lemma_frame_refl' p1 h01 h11;
lemma_frame_refl' p2 h02 h12
let lemma_frame_equalities frame h0 h1 p =
let p1 : prop = h0 frame == h1 frame in
let p2 : prop = frame_equalities' frame h0 h1 in
lemma_frame_refl' frame h0 h1;
FStar.PropositionalExtensionality.apply p1 p2
let lemma_frame_emp h0 h1 p =
FStar.PropositionalExtensionality.apply True (h0 (VUnit emp') == h1 (VUnit emp'))
let elim_conjunction p1 p1' p2 p2' = ()
let can_be_split_dep_refl p = ()
let equiv_can_be_split p1 p2 = ()
let intro_can_be_split_frame p q frame = ()
let can_be_split_post_elim t1 t2 = ()
let equiv_forall_refl t = ()
let equiv_forall_elim t1 t2 = ()
let equiv_refl x = ()
let equiv_sym x y = ()
let equiv_trans x y z = () | {
"checked_file": "/",
"dependencies": [
"Steel.Semantics.Instantiate.fsti.checked",
"Steel.Semantics.Hoare.MST.fst.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.PropositionalExtensionality.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.Effect.Common.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommMonoidSimple.Equiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": false,
"full_module": "Steel.Semantics.Instantiate",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "Steel.Semantics.Hoare.MST",
"short_module": "Sem"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Steel.Effect.Common.vprop
-> FStar.Pervasives.Lemma
(ensures Steel.Effect.Common.equiv (Steel.Effect.Common.star Steel.Effect.Common.emp x) x) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Memory.star_commutative",
"Steel.Effect.Common.hp_of",
"Steel.Memory.emp",
"Prims.unit",
"Steel.Memory.emp_unit"
] | [] | true | false | true | false | false | let cm_identity x =
| Mem.emp_unit (hp_of x);
Mem.star_commutative (hp_of x) Mem.emp | false |
Steel.Effect.Common.fst | Steel.Effect.Common.vrefine_am | val vrefine_am (v: vprop) (p: (t_of v -> Tot prop)) : Tot (a_mem_prop (hp_of v)) | val vrefine_am (v: vprop) (p: (t_of v -> Tot prop)) : Tot (a_mem_prop (hp_of v)) | let vrefine_am (v: vprop) (p: (t_of v -> Tot prop)) : Tot (a_mem_prop (hp_of v)) =
fun h -> p (sel_of v h) | {
"file_name": "lib/steel/Steel.Effect.Common.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 25,
"end_line": 115,
"start_col": 0,
"start_line": 114
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Effect.Common
module Sem = Steel.Semantics.Hoare.MST
module Mem = Steel.Memory
open Steel.Semantics.Instantiate
module FExt = FStar.FunctionalExtensionality
let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()})
let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q)
let reveal_can_be_split () = ()
let can_be_split_interp r r' h = ()
let can_be_split_trans p q r = ()
let can_be_split_star_l p q = ()
let can_be_split_star_r p q = ()
let can_be_split_refl p = ()
let can_be_split_congr_l p q r =
Classical.forall_intro (interp_star (hp_of p) (hp_of r));
Classical.forall_intro (interp_star (hp_of q) (hp_of r))
let can_be_split_congr_r p q r =
Classical.forall_intro (interp_star (hp_of r) (hp_of p));
Classical.forall_intro (interp_star (hp_of r) (hp_of q))
let equiv (p q:vprop) : prop = Mem.equiv (hp_of p) (hp_of q) /\ True
let reveal_equiv p q = ()
let valid_rmem (#frame:vprop) (h:rmem' frame) : prop =
forall (p p1 p2:vprop). can_be_split frame p /\ p == VStar p1 p2 ==>
(h p1, h p2) == h (VStar p1 p2)
let lemma_valid_mk_rmem (r:vprop) (h:hmem r) = ()
let reveal_mk_rmem (r:vprop) (h:hmem r) (r0:vprop{r `can_be_split` r0})
: Lemma ((mk_rmem r h) r0 == sel_of r0 h)
= FExt.feq_on_domain_g (unrestricted_mk_rmem r h)
let emp':vprop' =
{ hp = emp;
t = unit;
sel = fun _ -> ()}
let emp = VUnit emp'
let reveal_emp () = ()
let lemma_valid_focus_rmem #r h r0 =
Classical.forall_intro (Classical.move_requires (can_be_split_trans r r0))
let rec lemma_frame_refl' (frame:vprop) (h0:rmem frame) (h1:rmem frame)
: Lemma ((h0 frame == h1 frame) <==> frame_equalities' frame h0 h1)
= match frame with
| VUnit _ -> ()
| VStar p1 p2 ->
can_be_split_star_l p1 p2;
can_be_split_star_r p1 p2;
let h01 : rmem p1 = focus_rmem h0 p1 in
let h11 : rmem p1 = focus_rmem h1 p1 in
let h02 = focus_rmem h0 p2 in
let h12 = focus_rmem h1 p2 in
lemma_frame_refl' p1 h01 h11;
lemma_frame_refl' p2 h02 h12
let lemma_frame_equalities frame h0 h1 p =
let p1 : prop = h0 frame == h1 frame in
let p2 : prop = frame_equalities' frame h0 h1 in
lemma_frame_refl' frame h0 h1;
FStar.PropositionalExtensionality.apply p1 p2
let lemma_frame_emp h0 h1 p =
FStar.PropositionalExtensionality.apply True (h0 (VUnit emp') == h1 (VUnit emp'))
let elim_conjunction p1 p1' p2 p2' = ()
let can_be_split_dep_refl p = ()
let equiv_can_be_split p1 p2 = ()
let intro_can_be_split_frame p q frame = ()
let can_be_split_post_elim t1 t2 = ()
let equiv_forall_refl t = ()
let equiv_forall_elim t1 t2 = ()
let equiv_refl x = ()
let equiv_sym x y = ()
let equiv_trans x y z = ()
let cm_identity x =
Mem.emp_unit (hp_of x);
Mem.star_commutative (hp_of x) Mem.emp
let star_commutative p1 p2 = Mem.star_commutative (hp_of p1) (hp_of p2)
let star_associative p1 p2 p3 = Mem.star_associative (hp_of p1) (hp_of p2) (hp_of p3)
let star_congruence p1 p2 p3 p4 = Mem.star_congruence (hp_of p1) (hp_of p2) (hp_of p3) (hp_of p4) | {
"checked_file": "/",
"dependencies": [
"Steel.Semantics.Instantiate.fsti.checked",
"Steel.Semantics.Hoare.MST.fst.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.PropositionalExtensionality.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.Effect.Common.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommMonoidSimple.Equiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": false,
"full_module": "Steel.Semantics.Instantiate",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "Steel.Semantics.Hoare.MST",
"short_module": "Sem"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | v: Steel.Effect.Common.vprop -> p: (_: Steel.Effect.Common.t_of v -> Prims.prop)
-> Steel.Memory.a_mem_prop (Steel.Effect.Common.hp_of v) | Prims.Tot | [
"total"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.t_of",
"Prims.prop",
"Steel.Memory.hmem",
"Steel.Effect.Common.hp_of",
"Steel.Effect.Common.sel_of",
"Steel.Memory.a_mem_prop"
] | [] | false | false | false | false | false | let vrefine_am (v: vprop) (p: (t_of v -> Tot prop)) : Tot (a_mem_prop (hp_of v)) =
| fun h -> p (sel_of v h) | false |
FStar.OrdMap.fst | FStar.OrdMap.map_t | val map_t : k: Prims.eqtype -> v: Type -> f: FStar.OrdSet.cmp k -> d: FStar.OrdSet.ordset k f -> Type | let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)} | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 74,
"end_line": 23,
"start_col": 0,
"start_line": 22
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Prims.eqtype -> v: Type -> f: FStar.OrdSet.cmp k -> d: FStar.OrdSet.ordset k f -> Type | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdSet.ordset",
"FStar.FunctionalExtensionality.restricted_t",
"FStar.Pervasives.Native.option",
"Prims.l_Forall",
"Prims.eq2",
"Prims.bool",
"FStar.OrdSet.mem",
"FStar.Pervasives.Native.uu___is_Some"
] | [] | false | false | false | false | true | let map_t (k: eqtype) (v: Type) (f: cmp k) (d: ordset k f) =
| g: F.restricted_t k (fun _ -> option v) {forall x. mem x d == Some? (g x)} | false |
|
Steel.Effect.Common.fst | Steel.Effect.Common.vdep_sel | val vdep_sel (v: vprop) (p: ( (t_of v) -> Tot vprop)) : Tot (selector (vdep_t v p) (vdep_hp v p)) | val vdep_sel (v: vprop) (p: ( (t_of v) -> Tot vprop)) : Tot (selector (vdep_t v p) (vdep_hp v p)) | let vdep_sel
v p
= Classical.forall_intro_2 (Classical.move_requires_2 (fun (m0 m1: mem) -> (join_commutative m0) m1));
vdep_sel' v p | {
"file_name": "lib/steel/Steel.Effect.Common.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 15,
"end_line": 188,
"start_col": 0,
"start_line": 185
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Effect.Common
module Sem = Steel.Semantics.Hoare.MST
module Mem = Steel.Memory
open Steel.Semantics.Instantiate
module FExt = FStar.FunctionalExtensionality
let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()})
let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q)
let reveal_can_be_split () = ()
let can_be_split_interp r r' h = ()
let can_be_split_trans p q r = ()
let can_be_split_star_l p q = ()
let can_be_split_star_r p q = ()
let can_be_split_refl p = ()
let can_be_split_congr_l p q r =
Classical.forall_intro (interp_star (hp_of p) (hp_of r));
Classical.forall_intro (interp_star (hp_of q) (hp_of r))
let can_be_split_congr_r p q r =
Classical.forall_intro (interp_star (hp_of r) (hp_of p));
Classical.forall_intro (interp_star (hp_of r) (hp_of q))
let equiv (p q:vprop) : prop = Mem.equiv (hp_of p) (hp_of q) /\ True
let reveal_equiv p q = ()
let valid_rmem (#frame:vprop) (h:rmem' frame) : prop =
forall (p p1 p2:vprop). can_be_split frame p /\ p == VStar p1 p2 ==>
(h p1, h p2) == h (VStar p1 p2)
let lemma_valid_mk_rmem (r:vprop) (h:hmem r) = ()
let reveal_mk_rmem (r:vprop) (h:hmem r) (r0:vprop{r `can_be_split` r0})
: Lemma ((mk_rmem r h) r0 == sel_of r0 h)
= FExt.feq_on_domain_g (unrestricted_mk_rmem r h)
let emp':vprop' =
{ hp = emp;
t = unit;
sel = fun _ -> ()}
let emp = VUnit emp'
let reveal_emp () = ()
let lemma_valid_focus_rmem #r h r0 =
Classical.forall_intro (Classical.move_requires (can_be_split_trans r r0))
let rec lemma_frame_refl' (frame:vprop) (h0:rmem frame) (h1:rmem frame)
: Lemma ((h0 frame == h1 frame) <==> frame_equalities' frame h0 h1)
= match frame with
| VUnit _ -> ()
| VStar p1 p2 ->
can_be_split_star_l p1 p2;
can_be_split_star_r p1 p2;
let h01 : rmem p1 = focus_rmem h0 p1 in
let h11 : rmem p1 = focus_rmem h1 p1 in
let h02 = focus_rmem h0 p2 in
let h12 = focus_rmem h1 p2 in
lemma_frame_refl' p1 h01 h11;
lemma_frame_refl' p2 h02 h12
let lemma_frame_equalities frame h0 h1 p =
let p1 : prop = h0 frame == h1 frame in
let p2 : prop = frame_equalities' frame h0 h1 in
lemma_frame_refl' frame h0 h1;
FStar.PropositionalExtensionality.apply p1 p2
let lemma_frame_emp h0 h1 p =
FStar.PropositionalExtensionality.apply True (h0 (VUnit emp') == h1 (VUnit emp'))
let elim_conjunction p1 p1' p2 p2' = ()
let can_be_split_dep_refl p = ()
let equiv_can_be_split p1 p2 = ()
let intro_can_be_split_frame p q frame = ()
let can_be_split_post_elim t1 t2 = ()
let equiv_forall_refl t = ()
let equiv_forall_elim t1 t2 = ()
let equiv_refl x = ()
let equiv_sym x y = ()
let equiv_trans x y z = ()
let cm_identity x =
Mem.emp_unit (hp_of x);
Mem.star_commutative (hp_of x) Mem.emp
let star_commutative p1 p2 = Mem.star_commutative (hp_of p1) (hp_of p2)
let star_associative p1 p2 p3 = Mem.star_associative (hp_of p1) (hp_of p2) (hp_of p3)
let star_congruence p1 p2 p3 p4 = Mem.star_congruence (hp_of p1) (hp_of p2) (hp_of p3) (hp_of p4)
let vrefine_am (v: vprop) (p: (t_of v -> Tot prop)) : Tot (a_mem_prop (hp_of v)) =
fun h -> p (sel_of v h)
let vrefine_hp
v p
= refine_slprop (hp_of v) (vrefine_am v p)
let interp_vrefine_hp
v p m
= ()
let vrefine_sel' (v: vprop) (p: (t_of v -> Tot prop)) : Tot (selector' (vrefine_t v p) (vrefine_hp v p))
=
fun (h: Mem.hmem (vrefine_hp v p)) ->
interp_refine_slprop (hp_of v) (vrefine_am v p) h;
sel_of v h
let vrefine_sel
v p
= assert (sel_depends_only_on (vrefine_sel' v p));
assert (sel_depends_only_on_core (vrefine_sel' v p));
vrefine_sel' v p
let vrefine_sel_eq
v p m
= ()
let vdep_hp_payload
(v: vprop)
(p: (t_of v -> Tot vprop))
(h: Mem.hmem (hp_of v))
: Tot slprop
= hp_of (p (sel_of v h))
let vdep_hp
v p
=
sdep (hp_of v) (vdep_hp_payload v p)
let interp_vdep_hp
v p m
=
interp_sdep (hp_of v) (vdep_hp_payload v p) m;
let left = interp (vdep_hp v p) m in
let right = interp (hp_of v) m /\ interp (hp_of v `Mem.star` hp_of (p (sel_of v m))) m in
let f ()
: Lemma
(requires left)
(ensures right)
= interp_star (hp_of v) (hp_of (p (sel_of v m))) m
in
let g ()
: Lemma
(requires right)
(ensures left)
= interp_star (hp_of v) (hp_of (p (sel_of v m))) m
in
Classical.move_requires f ();
Classical.move_requires g ()
let vdep_sel'
(v: vprop)
(p: t_of v -> Tot vprop)
: Tot (selector' (vdep_t v p) (vdep_hp v p))
=
fun (m: Mem.hmem (vdep_hp v p)) ->
interp_vdep_hp v p m;
let x = sel_of v m in
let y = sel_of (p (sel_of v m)) m in
(| x, y |) | {
"checked_file": "/",
"dependencies": [
"Steel.Semantics.Instantiate.fsti.checked",
"Steel.Semantics.Hoare.MST.fst.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.PropositionalExtensionality.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.Effect.Common.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommMonoidSimple.Equiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": false,
"full_module": "Steel.Semantics.Instantiate",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "Steel.Semantics.Hoare.MST",
"short_module": "Sem"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | v: Steel.Effect.Common.vprop -> p: (_: Steel.Effect.Common.t_of v -> Steel.Effect.Common.vprop)
-> Steel.Effect.Common.selector (Steel.Effect.Common.vdep_t v p) (Steel.Effect.Common.vdep_hp v p) | Prims.Tot | [
"total"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.t_of",
"Steel.Effect.Common.vdep_sel'",
"Prims.unit",
"FStar.Classical.forall_intro_2",
"Steel.Memory.mem",
"Prims.l_imp",
"Steel.Memory.disjoint",
"Prims.l_and",
"Prims.eq2",
"Steel.Memory.join",
"FStar.Classical.move_requires_2",
"Steel.Memory.join_commutative",
"Steel.Effect.Common.selector",
"Steel.Effect.Common.vdep_t",
"Steel.Effect.Common.vdep_hp"
] | [] | false | false | false | false | false | let vdep_sel v p =
| Classical.forall_intro_2 (Classical.move_requires_2 (fun (m0: mem) (m1: mem) ->
(join_commutative m0) m1));
vdep_sel' v p | false |
FStar.OrdMap.fst | FStar.OrdMap.empty | val empty : #key:eqtype -> #value:Type -> #f:cmp key -> Tot (ordmap key value f) | val empty : #key:eqtype -> #value:Type -> #f:cmp key -> Tot (ordmap key value f) | let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 12,
"end_line": 32,
"start_col": 0,
"start_line": 29
} | (*
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.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.OrdMap.ordmap key value f | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdMap.Mk_map",
"FStar.FunctionalExtensionality.restricted_t",
"FStar.Pervasives.Native.option",
"FStar.FunctionalExtensionality.on_dom",
"FStar.Pervasives.Native.None",
"FStar.OrdSet.ordset",
"FStar.OrdSet.empty",
"FStar.OrdMap.ordmap"
] | [] | false | false | false | false | false | let empty (#k: eqtype) (#v: Type) #f =
| let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g | false |
Steel.ST.Array.fst | Steel.ST.Array.ptrdiff | val ptrdiff (#t:_) (#p0 #p1:perm) (#s0 #s1:Ghost.erased (Seq.seq t))
(a0:array t)
(a1:array t)
: ST UP.t
(pts_to a0 p0 s0 `star` pts_to a1 p1 s1)
(fun _ -> pts_to a0 p0 s0 `star` pts_to a1 p1 s1)
(base (ptr_of a0) == base (ptr_of a1) /\ UP.fits (offset (ptr_of a0) - offset (ptr_of a1)))
(fun r -> UP.v r == offset (ptr_of a0) - offset (ptr_of a1)) | val ptrdiff (#t:_) (#p0 #p1:perm) (#s0 #s1:Ghost.erased (Seq.seq t))
(a0:array t)
(a1:array t)
: ST UP.t
(pts_to a0 p0 s0 `star` pts_to a1 p1 s1)
(fun _ -> pts_to a0 p0 s0 `star` pts_to a1 p1 s1)
(base (ptr_of a0) == base (ptr_of a1) /\ UP.fits (offset (ptr_of a0) - offset (ptr_of a1)))
(fun r -> UP.v r == offset (ptr_of a0) - offset (ptr_of a1)) | let ptrdiff #_ #p0 #p1 #s0 #s1 a0 a1 =
rewrite
(pts_to a0 _ _)
(H.pts_to a0 p0 (seq_map raise s0));
rewrite
(pts_to a1 _ _)
(H.pts_to a1 p1 (seq_map raise s1));
let res = H.ptrdiff a0 a1 in
rewrite
(H.pts_to a1 _ _)
(pts_to a1 _ _);
rewrite
(H.pts_to a0 _ _)
(pts_to a0 _ _);
return res | {
"file_name": "lib/steel/Steel.ST.Array.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 12,
"end_line": 556,
"start_col": 0,
"start_line": 542
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
module US = FStar.SizeT
/// Lifting a value of universe 0 to universe 1. We use
/// FStar.Universe, since FStar.Extraction.Krml is set to extract
/// those functions to identity.
inline_for_extraction
[@@ noextract_to "krml"]
let raise_t (t: Type0) : Type u#1 = FStar.Universe.raise_t t
inline_for_extraction
[@@noextract_to "krml"]
let raise (#t: Type) (x: t) : Tot (raise_t t) =
FStar.Universe.raise_val x
inline_for_extraction
[@@noextract_to "krml"]
let lower (#t: Type) (x: raise_t t) : Tot t =
FStar.Universe.downgrade_val x
/// A map operation on sequences. Here we only need Ghost versions,
/// because such sequences are only used in vprops or with their
/// selectors.
let rec seq_map
(#t: Type u#a)
(#t' : Type u#b)
(f: (t -> GTot t'))
(s: Seq.seq t)
: Ghost (Seq.seq t')
(requires True)
(ensures (fun s' ->
Seq.length s' == Seq.length s /\
(forall i . {:pattern (Seq.index s' i)} Seq.index s' i == f (Seq.index s i))
))
(decreases (Seq.length s))
= if Seq.length s = 0
then Seq.empty
else Seq.cons (f (Seq.index s 0)) (seq_map f (Seq.slice s 1 (Seq.length s)))
let seq_map_append
(#t: Type u#a)
(#t': Type u#b)
(f: (t -> GTot t'))
(s1 s2: Seq.seq t)
: Lemma
(seq_map f (s1 `Seq.append` s2) `Seq.equal` (seq_map f s1 `Seq.append` seq_map f s2))
= ()
let seq_map_raise_inj
(#elt: Type0)
(s1 s2: Seq.seq elt)
: Lemma
(requires (seq_map raise s1 == seq_map raise s2))
(ensures (s1 == s2))
[SMTPat (seq_map raise s1); SMTPat (seq_map raise s2)]
= assert (seq_map lower (seq_map raise s1) `Seq.equal` s1);
assert (seq_map lower (seq_map raise s2) `Seq.equal` s2)
/// Implementation of the interface
/// base, ptr, array, pts_to
module H = Steel.ST.HigherArray
let base_t elt = H.base_t (raise_t elt)
let base_len b = H.base_len b
let ptr elt = H.ptr (raise_t elt)
let null_ptr elt = H.null_ptr (raise_t elt)
let is_null_ptr p = H.is_null_ptr p
let base p = H.base p
let offset p = H.offset p
let ptr_base_offset_inj p1 p2 = H.ptr_base_offset_inj p1 p2
let base_len_null_ptr elt = H.base_len_null_ptr (raise_t elt)
let length_fits a = H.length_fits a
let pts_to a p s = H.pts_to a p (seq_map raise s)
let pts_to_length a s =
H.pts_to_length a _
let h_array_eq'
(#t: Type u#1)
(a1 a2: H.array t)
: Lemma
(requires (
dfst a1 == dfst a2 /\
(Ghost.reveal (dsnd a1) <: nat) == Ghost.reveal (dsnd a2)
))
(ensures (
a1 == a2
))
= ()
let pts_to_not_null #_ #t #p a s =
let _ = H.pts_to_not_null #_ #_ #p a (seq_map raise s) in
assert (a =!= H.null #(raise_t t));
Classical.move_requires (h_array_eq' a) (H.null #(raise_t t));
noop ()
let pts_to_inj a p1 s1 p2 s2 =
H.pts_to_inj a p1 (seq_map raise s1) p2 (seq_map raise s2)
/// Non-selector operations.
let malloc x n =
let res = H.malloc (raise x) n in
assert (seq_map raise (Seq.create (US.v n) x) `Seq.equal` Seq.create (US.v n) (raise x));
rewrite
(H.pts_to res _ _)
(pts_to res _ _);
return res
let free #_ x =
let s = elim_exists () in
rewrite
(pts_to x _ _)
(H.pts_to x P.full_perm (seq_map raise s));
H.free x
let share
#_ #_ #x a p p1 p2
= rewrite
(pts_to a _ _)
(H.pts_to a p (seq_map raise x));
H.share a p p1 p2;
rewrite
(H.pts_to a p1 _)
(pts_to a p1 x);
rewrite
(H.pts_to a p2 _)
(pts_to a p2 x)
let gather
#_ #_ a #x1 p1 #x2 p2
= rewrite
(pts_to a p1 _)
(H.pts_to a p1 (seq_map raise x1));
rewrite
(pts_to a p2 _)
(H.pts_to a p2 (seq_map raise x2));
H.gather a p1 p2;
rewrite
(H.pts_to a _ _)
(pts_to _ _ _)
let index #_ #p a #s i =
rewrite
(pts_to a _ _)
(H.pts_to a p (seq_map raise s));
let res = H.index a i in
rewrite
(H.pts_to _ _ _)
(pts_to _ _ _);
return (lower res)
let upd #_ a #s i v =
rewrite
(pts_to a _ _)
(H.pts_to a P.full_perm (seq_map raise s));
H.upd a i (raise v);
assert (seq_map raise (Seq.upd s (US.v i) v) `Seq.equal` Seq.upd (seq_map raise s) (US.v i) (raise v));
rewrite
(H.pts_to _ _ _)
(pts_to _ _ _)
let ghost_join
#_ #_ #x1 #x2 #p a1 a2 h
= rewrite
(pts_to a1 _ _)
(H.pts_to a1 p (seq_map raise x1));
rewrite
(pts_to a2 _ _)
(H.pts_to a2 p (seq_map raise x2));
H.ghost_join a1 a2 h;
assert (seq_map raise (x1 `Seq.append` x2) `Seq.equal` (seq_map raise x1 `Seq.append` seq_map raise x2));
rewrite
(H.pts_to _ _ _)
(H.pts_to (merge a1 a2) p (seq_map raise (x1 `Seq.append` x2)));
rewrite
(H.pts_to _ _ _)
(pts_to (merge a1 a2) _ _)
let ptr_shift p off = H.ptr_shift p off
let ghost_split
#_ #_ #x #p a i
=
rewrite
(pts_to a _ _)
(H.pts_to a p (seq_map raise x));
let _ = H.ghost_split a i in
//H.ghost_split a i;
assert (seq_map raise (Seq.slice x 0 (US.v i)) `Seq.equal` Seq.slice (seq_map raise x) 0 (US.v i));
rewrite
(H.pts_to (H.split_l a i) _ _)
(H.pts_to (split_l a i) p (seq_map raise (Seq.slice x 0 (US.v i))));
rewrite
(H.pts_to (split_l a i) _ _)
(pts_to (split_l a i) _ _);
assert (seq_map raise (Seq.slice x (US.v i) (Seq.length x)) `Seq.equal` Seq.slice (seq_map raise x) (US.v i) (Seq.length (seq_map raise x)));
Seq.lemma_split x (US.v i);
rewrite
(H.pts_to (H.split_r a i) _ _)
(H.pts_to (split_r a i) p (seq_map raise (Seq.slice x (US.v i) (Seq.length x))));
rewrite
(H.pts_to (split_r a i) _ _)
(pts_to (split_r a i) _ _)
let memcpy
a0 a1 l
=
H.memcpy a0 a1 l
////////////////////////////////////////////////////////////////////////////////
// compare
////////////////////////////////////////////////////////////////////////////////
module R = Steel.ST.Reference
#push-options "--fuel 0 --ifuel 1 --z3rlimit_factor 2"
let equal_up_to #t
(s0: Seq.seq t)
(s1: Seq.seq t)
(v : option US.t) : prop =
Seq.length s0 = Seq.length s1 /\
(match v with
| None -> Ghost.reveal s0 =!= Ghost.reveal s1
| Some v -> US.v v <= Seq.length s0 /\ Seq.slice s0 0 (US.v v) `Seq.equal` Seq.slice s1 0 (US.v v))
let within_bounds (x:option US.t) (l:US.t) (b:Ghost.erased bool) : prop =
if b then Some? x /\ US.(Some?.v x <^ l)
else None? x \/ US.(Some?.v x >=^ l)
let compare_inv (#t:eqtype) (#p0 #p1:perm)
(a0 a1:array t)
(s0: Seq.seq t)
(s1: Seq.seq t)
(l:US.t)
(ctr : R.ref (option US.t))
(b: bool) =
pts_to a0 p0 s0 `star`
pts_to a1 p1 s1 `star`
exists_ (fun (x:option US.t) ->
R.pts_to ctr Steel.FractionalPermission.full_perm x `star`
pure (equal_up_to s0 s1 x) `star`
pure (within_bounds x l b))
let elim_compare_inv #o
(#t:eqtype)
(#p0 #p1:perm)
(a0 a1:array t)
(#s0: Seq.seq t)
(#s1: Seq.seq t)
(l:US.t)
(ctr : R.ref (option US.t))
(b: bool)
: STGhostT (Ghost.erased (option US.t)) o
(compare_inv a0 a1 s0 s1 l ctr b)
(fun x ->
let open US in
pts_to a0 p0 s0 `star`
pts_to a1 p1 s1 `star`
R.pts_to ctr Steel.FractionalPermission.full_perm x `star`
pure (equal_up_to s0 s1 x) `star`
pure (within_bounds x l b))
= let open US in
assert_spinoff
((compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr b) ==
(pts_to a0 p0 s0 `star`
pts_to a1 p1 s1 `star`
exists_ (fun (v:option US.t) ->
R.pts_to ctr Steel.FractionalPermission.full_perm v `star`
pure (equal_up_to s0 s1 v) `star`
pure (within_bounds v l b))));
rewrite
(compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr b)
(pts_to a0 p0 s0 `star`
pts_to a1 p1 s1 `star`
exists_ (fun (v:option US.t) ->
R.pts_to ctr Steel.FractionalPermission.full_perm v `star`
pure (equal_up_to s0 s1 v) `star`
pure (within_bounds v l b)));
let _v = elim_exists () in
_v
let intro_compare_inv #o
(#t:eqtype)
(#p0 #p1:perm)
(a0 a1:array t)
(#s0: Seq.seq t)
(#s1: Seq.seq t)
(l:US.t)
(ctr : R.ref (option US.t))
(x: Ghost.erased (option US.t))
(b:bool { within_bounds x l b })
: STGhostT unit o
(let open US in
pts_to a0 p0 s0 `star`
pts_to a1 p1 s1 `star`
R.pts_to ctr Steel.FractionalPermission.full_perm x `star`
pure (equal_up_to s0 s1 x))
(fun _ -> compare_inv a0 a1 s0 s1 l ctr (Ghost.hide b))
= let open US in
intro_pure (within_bounds x l (Ghost.hide b));
intro_exists_erased x (fun (x:option US.t) ->
R.pts_to ctr Steel.FractionalPermission.full_perm x `star`
pure (equal_up_to s0 s1 x) `star`
pure (within_bounds x l (Ghost.hide b)));
assert_norm
((compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr (Ghost.hide b)) ==
(pts_to a0 p0 s0 `star`
pts_to a1 p1 s1 `star`
exists_ (fun (v:option US.t) ->
R.pts_to ctr Steel.FractionalPermission.full_perm v `star`
pure (equal_up_to s0 s1 v) `star`
pure (within_bounds v l (Ghost.hide b)))));
rewrite
(pts_to a0 p0 s0 `star`
pts_to a1 p1 s1 `star`
exists_ (fun (v:option US.t) ->
R.pts_to ctr Steel.FractionalPermission.full_perm v `star`
pure (equal_up_to s0 s1 v) `star`
pure (within_bounds v l (Ghost.hide b))))
(compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr (Ghost.hide b))
let intro_exists_compare_inv #o
(#t:eqtype)
(#p0 #p1:perm)
(a0 a1:array t)
(#s0: Seq.seq t)
(#s1: Seq.seq t)
(l:US.t)
(ctr : R.ref (option US.t))
(x: Ghost.erased (option US.t))
: STGhostT unit o
(let open US in
pts_to a0 p0 s0 `star`
pts_to a1 p1 s1 `star`
R.pts_to ctr Steel.FractionalPermission.full_perm x `star`
pure (equal_up_to s0 s1 x))
(fun _ -> exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr))
= let b : bool =
match Ghost.reveal x with
| None -> false
| Some x -> US.(x <^ l)
in
assert (within_bounds x l b);
intro_compare_inv #_ #_ #p0 #p1 a0 a1 #s0 #s1 l ctr x b;
intro_exists _ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr)
let extend_equal_up_to_lemma (#t:Type0)
(s0:Seq.seq t)
(s1:Seq.seq t)
(i:nat{ i < Seq.length s0 /\ Seq.length s0 == Seq.length s1 })
: Lemma
(requires
Seq.equal (Seq.slice s0 0 i) (Seq.slice s1 0 i) /\
Seq.index s0 i == Seq.index s1 i)
(ensures
Seq.equal (Seq.slice s0 0 (i + 1)) (Seq.slice s1 0 (i + 1)))
= assert (forall k. k < i ==> Seq.index s0 k == Seq.index (Seq.slice s0 0 i) k /\
Seq.index s1 k == Seq.index (Seq.slice s1 0 i) k)
let extend_equal_up_to (#o:_)
(#t:Type0)
(#s0:Seq.seq t)
(#s1:Seq.seq t)
(len:US.t)
(i:US.t{ Seq.length s0 == Seq.length s1 /\ US.(i <^ len) /\ US.v len == Seq.length s0 } )
: STGhost unit o
(pure (equal_up_to s0 s1 (Some i)))
(fun _ -> pure (equal_up_to s0 s1 (Some US.(i +^ 1sz))))
(requires
Seq.index s0 (US.v i) == Seq.index s1 (US.v i))
(ensures fun _ -> True)
= elim_pure _;
extend_equal_up_to_lemma s0 s1 (US.v i);
intro_pure (equal_up_to s0 s1 (Some US.(i +^ 1sz)))
let extend_equal_up_to_neg (#o:_)
(#t:Type0)
(#s0:Seq.seq t)
(#s1:Seq.seq t)
(len:US.t)
(i:US.t{ Seq.length s0 == Seq.length s1 /\ US.(i <^ len) /\ US.v len == Seq.length s0 } )
: STGhost unit o
(pure (equal_up_to s0 s1 (Some i)))
(fun _ -> pure (equal_up_to s0 s1 None))
(requires
Seq.index s0 (US.v i) =!= Seq.index s1 (US.v i))
(ensures fun _ -> True)
= elim_pure _;
intro_pure _
let init_compare_inv #o
(#t:eqtype)
(#p0 #p1:perm)
(a0 a1:array t)
(#s0: Seq.seq t)
(#s1: Seq.seq t)
(l:US.t)
(ctr : R.ref (option US.t))
: STGhost unit o
(let open US in
pts_to a0 p0 s0 `star`
pts_to a1 p1 s1 `star`
R.pts_to ctr Steel.FractionalPermission.full_perm (Some 0sz))
(fun _ -> exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr))
(requires (
length a0 > 0 /\
length a0 == length a1 /\
US.v l == length a0
))
(ensures (fun _ -> True))
= pts_to_length a0 _;
pts_to_length a1 _;
intro_pure (equal_up_to s0 s1 (Ghost.hide (Some 0sz)));
rewrite
(R.pts_to ctr Steel.FractionalPermission.full_perm (Some 0sz))
(R.pts_to ctr Steel.FractionalPermission.full_perm (Ghost.hide (Some 0sz)));
intro_exists_compare_inv a0 a1 l ctr (Ghost.hide (Some 0sz))
let compare_pts
(#t:eqtype)
(#p0 #p1:perm)
(a0 a1:array t)
(#s0: Ghost.erased (Seq.seq t))
(#s1: Ghost.erased (Seq.seq t))
(l:US.t)
: ST bool
(pts_to a0 p0 s0 `star` pts_to a1 p1 s1)
(fun _ -> pts_to a0 p0 s0 `star` pts_to a1 p1 s1)
(requires
length a0 > 0 /\ length a0 == length a1 /\ US.v l == length a0
)
(ensures fun b ->
b = (Ghost.reveal s0 = Ghost.reveal s1))
=
pts_to_length a0 _;
pts_to_length a1 _;
let ctr = R.alloc (Some 0sz) in
let cond ()
: STT bool
(exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr))
(fun b -> compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr (Ghost.hide b))
= let _b = elim_exists () in
let _ = elim_compare_inv _ _ _ _ _ in
let x = R.read ctr in
elim_pure (within_bounds _ _ _);
match x with
| None ->
intro_compare_inv #_ #_ #p0 #p1 a0 a1 l ctr _ false;
return false
| Some x ->
let res = US.(x <^ l) in
intro_compare_inv #_ #_ #p0 #p1 a0 a1 l ctr _ res;
return res
in
let body ()
: STT unit
(compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr (Ghost.hide true))
(fun _ -> exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr))
= let _i = elim_compare_inv _ _ _ _ _ in
elim_pure (within_bounds _ _ _);
let Some i = R.read ctr in
assert_spinoff
((pure (equal_up_to s0 s1 _i)) ==
(pure (equal_up_to s0 s1 (Some i))));
rewrite
(pure (equal_up_to s0 s1 _i))
(pure (equal_up_to s0 s1 (Some i)));
let v0 = index a0 i in
let v1 = index a1 i in
if v0 = v1
then (
R.write ctr (Some US.(i +^ 1sz));
extend_equal_up_to l i;
intro_exists_compare_inv #_ #_ #p0 #p1 a0 a1 l ctr (Ghost.hide (Some (US.(i +^ 1sz))))
)
else (
R.write ctr None;
extend_equal_up_to_neg l i;
intro_exists_compare_inv #_ #_ #p0 #p1 a0 a1 l ctr (Ghost.hide None)
)
in
init_compare_inv a0 a1 l ctr;
Steel.ST.Loops.while_loop (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr)
cond
body;
let _ = elim_compare_inv _ _ _ _ _ in
elim_pure (equal_up_to _ _ _);
let v = R.read ctr in
R.free ctr;
elim_pure (within_bounds _ _ _);
match v with
| None -> return false
| Some _ -> return true
let compare
#t #p0 #p1 a0 a1 #s0 #s1 l
=
pts_to_length a0 _;
pts_to_length a1 _;
if l = 0sz
then (
assert (Seq.equal s0 s1);
return true
)
else (
compare_pts a0 a1 l
)
#pop-options
let intro_fits_u32 () = H.intro_fits_u32 ()
let intro_fits_u64 () = H.intro_fits_u64 ()
let intro_fits_ptrdiff32 () = H.intro_fits_ptrdiff32 ()
let intro_fits_ptrdiff64 () = H.intro_fits_ptrdiff64 () | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Reference.fsti.checked",
"Steel.ST.Loops.fsti.checked",
"Steel.ST.HigherArray.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.Array.fst"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.Reference",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a0: Steel.ST.Array.array t -> a1: Steel.ST.Array.array t -> Steel.ST.Effect.ST FStar.PtrdiffT.t | Steel.ST.Effect.ST | [] | [] | [
"Steel.FractionalPermission.perm",
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Steel.ST.Array.array",
"Steel.ST.Util.return",
"FStar.PtrdiffT.t",
"FStar.Ghost.hide",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.empty",
"Steel.Effect.Common.VStar",
"Steel.ST.Array.pts_to",
"FStar.Ghost.reveal",
"Steel.Effect.Common.vprop",
"Prims.unit",
"Steel.ST.Util.rewrite",
"Steel.ST.HigherArray.pts_to",
"Steel.ST.Array.raise_t",
"Steel.ST.Array.seq_map",
"Steel.ST.Array.raise",
"Steel.ST.HigherArray.ptrdiff"
] | [] | false | true | false | false | false | let ptrdiff #_ #p0 #p1 #s0 #s1 a0 a1 =
| rewrite (pts_to a0 _ _) (H.pts_to a0 p0 (seq_map raise s0));
rewrite (pts_to a1 _ _) (H.pts_to a1 p1 (seq_map raise s1));
let res = H.ptrdiff a0 a1 in
rewrite (H.pts_to a1 _ _) (pts_to a1 _ _);
rewrite (H.pts_to a0 _ _) (pts_to a0 _ _);
return res | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.op_String_Access | val op_String_Access : s: Lib.Sequence.lseq a len -> i: (n: Prims.nat{n <= Prims.pow2 32 - 1}){i < len}
-> r: a{r == FStar.Seq.Base.index (Lib.Sequence.to_seq s) i} | let op_String_Access #a #len = LSeq.index #a #len | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 49,
"end_line": 46,
"start_col": 0,
"start_line": 46
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s) | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Lib.Sequence.lseq a len -> i: (n: Prims.nat{n <= Prims.pow2 32 - 1}){i < len}
-> r: a{r == FStar.Seq.Base.index (Lib.Sequence.to_seq s) i} | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.size_nat",
"Lib.Sequence.index",
"Lib.Sequence.lseq",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2",
"Prims.op_LessThan",
"Prims.eq2",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq"
] | [] | false | false | false | false | false | let ( .[] ) #a #len =
| LSeq.index #a #len | false |
|
FStar.OrdMap.fst | FStar.OrdMap.insert | val insert : x: a -> s: FStar.OrdSet.ordset a f -> FStar.OrdSet.ordset a f | let insert (#a:eqtype) (#f:cmp a) (x:a) (s:ordset a f) = union #a #f (singleton #a #f x) s | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 90,
"end_line": 40,
"start_col": 0,
"start_line": 40
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f
let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g
let const_on (#k:eqtype) (#v:Type) #f d x =
let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g
let select (#k:eqtype) (#v:Type) #f x m = (Mk_map?.m m) x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: a -> s: FStar.OrdSet.ordset a f -> FStar.OrdSet.ordset a f | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdSet.ordset",
"FStar.OrdSet.union",
"FStar.OrdSet.singleton"
] | [] | false | false | false | false | false | let insert (#a: eqtype) (#f: cmp a) (x: a) (s: ordset a f) =
| union #a #f (singleton #a #f x) s | false |
|
FStar.OrdMap.fst | FStar.OrdMap.const_on | val const_on: #key:eqtype -> #value:Type -> #f:cmp key -> d:ordset key f -> x:value -> Tot (ordmap key value f) | val const_on: #key:eqtype -> #value:Type -> #f:cmp key -> d:ordset key f -> x:value -> Tot (ordmap key value f) | let const_on (#k:eqtype) (#v:Type) #f d x =
let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 12,
"end_line": 36,
"start_col": 0,
"start_line": 34
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f
let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | d: FStar.OrdSet.ordset key f -> x: value -> FStar.OrdMap.ordmap key value f | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdSet.ordset",
"FStar.OrdMap.Mk_map",
"FStar.FunctionalExtensionality.restricted_t",
"FStar.Pervasives.Native.option",
"FStar.FunctionalExtensionality.on_dom",
"FStar.OrdSet.mem",
"FStar.Pervasives.Native.Some",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.OrdMap.ordmap"
] | [] | false | false | false | false | false | let const_on (#k: eqtype) (#v: Type) #f d x =
| let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g | false |
FStar.OrdMap.fst | FStar.OrdMap.contains | val contains: #key:eqtype -> #value:Type -> #f:cmp key -> key -> ordmap key value f
-> Tot bool | val contains: #key:eqtype -> #value:Type -> #f:cmp key -> key -> ordmap key value f
-> Tot bool | let contains (#k:eqtype) (#v:Type) #f x m = mem x (Mk_map?.d m) | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 63,
"end_line": 47,
"start_col": 0,
"start_line": 47
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f
let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g
let const_on (#k:eqtype) (#v:Type) #f d x =
let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g
let select (#k:eqtype) (#v:Type) #f x m = (Mk_map?.m m) x
let insert (#a:eqtype) (#f:cmp a) (x:a) (s:ordset a f) = union #a #f (singleton #a #f x) s
let update (#k:eqtype) (#v:Type) #f x y m =
let s' = insert x (Mk_map?.d m) in
let g' = F.on_dom k (fun (x':k) -> if x' = x then Some y else (Mk_map?.m m) x') in
Mk_map s' g' | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: key -> m: FStar.OrdMap.ordmap key value f -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdMap.ordmap",
"FStar.OrdSet.mem",
"FStar.OrdMap.__proj__Mk_map__item__d",
"Prims.bool"
] | [] | false | false | false | false | false | let contains (#k: eqtype) (#v: Type) #f x m =
| mem x (Mk_map?.d m) | false |
Steel.Effect.Common.fst | Steel.Effect.Common.vrefine_sel' | val vrefine_sel' (v: vprop) (p: (t_of v -> Tot prop))
: Tot (selector' (vrefine_t v p) (vrefine_hp v p)) | val vrefine_sel' (v: vprop) (p: (t_of v -> Tot prop))
: Tot (selector' (vrefine_t v p) (vrefine_hp v p)) | let vrefine_sel' (v: vprop) (p: (t_of v -> Tot prop)) : Tot (selector' (vrefine_t v p) (vrefine_hp v p))
=
fun (h: Mem.hmem (vrefine_hp v p)) ->
interp_refine_slprop (hp_of v) (vrefine_am v p) h;
sel_of v h | {
"file_name": "lib/steel/Steel.Effect.Common.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 14,
"end_line": 129,
"start_col": 0,
"start_line": 125
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Effect.Common
module Sem = Steel.Semantics.Hoare.MST
module Mem = Steel.Memory
open Steel.Semantics.Instantiate
module FExt = FStar.FunctionalExtensionality
let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()})
let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q)
let reveal_can_be_split () = ()
let can_be_split_interp r r' h = ()
let can_be_split_trans p q r = ()
let can_be_split_star_l p q = ()
let can_be_split_star_r p q = ()
let can_be_split_refl p = ()
let can_be_split_congr_l p q r =
Classical.forall_intro (interp_star (hp_of p) (hp_of r));
Classical.forall_intro (interp_star (hp_of q) (hp_of r))
let can_be_split_congr_r p q r =
Classical.forall_intro (interp_star (hp_of r) (hp_of p));
Classical.forall_intro (interp_star (hp_of r) (hp_of q))
let equiv (p q:vprop) : prop = Mem.equiv (hp_of p) (hp_of q) /\ True
let reveal_equiv p q = ()
let valid_rmem (#frame:vprop) (h:rmem' frame) : prop =
forall (p p1 p2:vprop). can_be_split frame p /\ p == VStar p1 p2 ==>
(h p1, h p2) == h (VStar p1 p2)
let lemma_valid_mk_rmem (r:vprop) (h:hmem r) = ()
let reveal_mk_rmem (r:vprop) (h:hmem r) (r0:vprop{r `can_be_split` r0})
: Lemma ((mk_rmem r h) r0 == sel_of r0 h)
= FExt.feq_on_domain_g (unrestricted_mk_rmem r h)
let emp':vprop' =
{ hp = emp;
t = unit;
sel = fun _ -> ()}
let emp = VUnit emp'
let reveal_emp () = ()
let lemma_valid_focus_rmem #r h r0 =
Classical.forall_intro (Classical.move_requires (can_be_split_trans r r0))
let rec lemma_frame_refl' (frame:vprop) (h0:rmem frame) (h1:rmem frame)
: Lemma ((h0 frame == h1 frame) <==> frame_equalities' frame h0 h1)
= match frame with
| VUnit _ -> ()
| VStar p1 p2 ->
can_be_split_star_l p1 p2;
can_be_split_star_r p1 p2;
let h01 : rmem p1 = focus_rmem h0 p1 in
let h11 : rmem p1 = focus_rmem h1 p1 in
let h02 = focus_rmem h0 p2 in
let h12 = focus_rmem h1 p2 in
lemma_frame_refl' p1 h01 h11;
lemma_frame_refl' p2 h02 h12
let lemma_frame_equalities frame h0 h1 p =
let p1 : prop = h0 frame == h1 frame in
let p2 : prop = frame_equalities' frame h0 h1 in
lemma_frame_refl' frame h0 h1;
FStar.PropositionalExtensionality.apply p1 p2
let lemma_frame_emp h0 h1 p =
FStar.PropositionalExtensionality.apply True (h0 (VUnit emp') == h1 (VUnit emp'))
let elim_conjunction p1 p1' p2 p2' = ()
let can_be_split_dep_refl p = ()
let equiv_can_be_split p1 p2 = ()
let intro_can_be_split_frame p q frame = ()
let can_be_split_post_elim t1 t2 = ()
let equiv_forall_refl t = ()
let equiv_forall_elim t1 t2 = ()
let equiv_refl x = ()
let equiv_sym x y = ()
let equiv_trans x y z = ()
let cm_identity x =
Mem.emp_unit (hp_of x);
Mem.star_commutative (hp_of x) Mem.emp
let star_commutative p1 p2 = Mem.star_commutative (hp_of p1) (hp_of p2)
let star_associative p1 p2 p3 = Mem.star_associative (hp_of p1) (hp_of p2) (hp_of p3)
let star_congruence p1 p2 p3 p4 = Mem.star_congruence (hp_of p1) (hp_of p2) (hp_of p3) (hp_of p4)
let vrefine_am (v: vprop) (p: (t_of v -> Tot prop)) : Tot (a_mem_prop (hp_of v)) =
fun h -> p (sel_of v h)
let vrefine_hp
v p
= refine_slprop (hp_of v) (vrefine_am v p)
let interp_vrefine_hp
v p m
= () | {
"checked_file": "/",
"dependencies": [
"Steel.Semantics.Instantiate.fsti.checked",
"Steel.Semantics.Hoare.MST.fst.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.PropositionalExtensionality.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.Effect.Common.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommMonoidSimple.Equiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": false,
"full_module": "Steel.Semantics.Instantiate",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "Steel.Semantics.Hoare.MST",
"short_module": "Sem"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | v: Steel.Effect.Common.vprop -> p: (_: Steel.Effect.Common.t_of v -> Prims.prop)
-> Steel.Effect.Common.selector' (Steel.Effect.Common.vrefine_t v p)
(Steel.Effect.Common.vrefine_hp v p) | Prims.Tot | [
"total"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.t_of",
"Prims.prop",
"Steel.Memory.hmem",
"Steel.Effect.Common.vrefine_hp",
"Steel.Effect.Common.sel_of",
"Prims.unit",
"Steel.Memory.interp_refine_slprop",
"Steel.Effect.Common.hp_of",
"Steel.Effect.Common.vrefine_am",
"Steel.Effect.Common.vrefine_t",
"Steel.Effect.Common.selector'"
] | [] | false | false | false | false | false | let vrefine_sel' (v: vprop) (p: (t_of v -> Tot prop))
: Tot (selector' (vrefine_t v p) (vrefine_hp v p)) =
| fun (h: Mem.hmem (vrefine_hp v p)) ->
interp_refine_slprop (hp_of v) (vrefine_am v p) h;
sel_of v h | false |
FStar.OrdMap.fst | FStar.OrdMap.select | val select : #key:eqtype -> #value:Type -> #f:cmp key -> k:key
-> m:ordmap key value f -> Tot (option value) | val select : #key:eqtype -> #value:Type -> #f:cmp key -> k:key
-> m:ordmap key value f -> Tot (option value) | let select (#k:eqtype) (#v:Type) #f x m = (Mk_map?.m m) x | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 57,
"end_line": 38,
"start_col": 0,
"start_line": 38
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f
let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g
let const_on (#k:eqtype) (#v:Type) #f d x =
let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: key -> m: FStar.OrdMap.ordmap key value f -> FStar.Pervasives.Native.option value | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdMap.ordmap",
"FStar.OrdMap.__proj__Mk_map__item__m",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | false | false | let select (#k: eqtype) (#v: Type) #f x m =
| (Mk_map?.m m) x | false |
Steel.Effect.Common.fst | Steel.Effect.Common.interp_vdep_hp | val interp_vdep_hp (v: vprop) (p: ( (t_of v) -> Tot vprop)) (m: mem) : Lemma
(interp (vdep_hp v p) m <==> (interp (hp_of v) m /\ interp (hp_of v `Mem.star` hp_of (p (sel_of v m))) m)) | val interp_vdep_hp (v: vprop) (p: ( (t_of v) -> Tot vprop)) (m: mem) : Lemma
(interp (vdep_hp v p) m <==> (interp (hp_of v) m /\ interp (hp_of v `Mem.star` hp_of (p (sel_of v m))) m)) | let interp_vdep_hp
v p m
=
interp_sdep (hp_of v) (vdep_hp_payload v p) m;
let left = interp (vdep_hp v p) m in
let right = interp (hp_of v) m /\ interp (hp_of v `Mem.star` hp_of (p (sel_of v m))) m in
let f ()
: Lemma
(requires left)
(ensures right)
= interp_star (hp_of v) (hp_of (p (sel_of v m))) m
in
let g ()
: Lemma
(requires right)
(ensures left)
= interp_star (hp_of v) (hp_of (p (sel_of v m))) m
in
Classical.move_requires f ();
Classical.move_requires g () | {
"file_name": "lib/steel/Steel.Effect.Common.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 30,
"end_line": 172,
"start_col": 0,
"start_line": 153
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Effect.Common
module Sem = Steel.Semantics.Hoare.MST
module Mem = Steel.Memory
open Steel.Semantics.Instantiate
module FExt = FStar.FunctionalExtensionality
let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()})
let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q)
let reveal_can_be_split () = ()
let can_be_split_interp r r' h = ()
let can_be_split_trans p q r = ()
let can_be_split_star_l p q = ()
let can_be_split_star_r p q = ()
let can_be_split_refl p = ()
let can_be_split_congr_l p q r =
Classical.forall_intro (interp_star (hp_of p) (hp_of r));
Classical.forall_intro (interp_star (hp_of q) (hp_of r))
let can_be_split_congr_r p q r =
Classical.forall_intro (interp_star (hp_of r) (hp_of p));
Classical.forall_intro (interp_star (hp_of r) (hp_of q))
let equiv (p q:vprop) : prop = Mem.equiv (hp_of p) (hp_of q) /\ True
let reveal_equiv p q = ()
let valid_rmem (#frame:vprop) (h:rmem' frame) : prop =
forall (p p1 p2:vprop). can_be_split frame p /\ p == VStar p1 p2 ==>
(h p1, h p2) == h (VStar p1 p2)
let lemma_valid_mk_rmem (r:vprop) (h:hmem r) = ()
let reveal_mk_rmem (r:vprop) (h:hmem r) (r0:vprop{r `can_be_split` r0})
: Lemma ((mk_rmem r h) r0 == sel_of r0 h)
= FExt.feq_on_domain_g (unrestricted_mk_rmem r h)
let emp':vprop' =
{ hp = emp;
t = unit;
sel = fun _ -> ()}
let emp = VUnit emp'
let reveal_emp () = ()
let lemma_valid_focus_rmem #r h r0 =
Classical.forall_intro (Classical.move_requires (can_be_split_trans r r0))
let rec lemma_frame_refl' (frame:vprop) (h0:rmem frame) (h1:rmem frame)
: Lemma ((h0 frame == h1 frame) <==> frame_equalities' frame h0 h1)
= match frame with
| VUnit _ -> ()
| VStar p1 p2 ->
can_be_split_star_l p1 p2;
can_be_split_star_r p1 p2;
let h01 : rmem p1 = focus_rmem h0 p1 in
let h11 : rmem p1 = focus_rmem h1 p1 in
let h02 = focus_rmem h0 p2 in
let h12 = focus_rmem h1 p2 in
lemma_frame_refl' p1 h01 h11;
lemma_frame_refl' p2 h02 h12
let lemma_frame_equalities frame h0 h1 p =
let p1 : prop = h0 frame == h1 frame in
let p2 : prop = frame_equalities' frame h0 h1 in
lemma_frame_refl' frame h0 h1;
FStar.PropositionalExtensionality.apply p1 p2
let lemma_frame_emp h0 h1 p =
FStar.PropositionalExtensionality.apply True (h0 (VUnit emp') == h1 (VUnit emp'))
let elim_conjunction p1 p1' p2 p2' = ()
let can_be_split_dep_refl p = ()
let equiv_can_be_split p1 p2 = ()
let intro_can_be_split_frame p q frame = ()
let can_be_split_post_elim t1 t2 = ()
let equiv_forall_refl t = ()
let equiv_forall_elim t1 t2 = ()
let equiv_refl x = ()
let equiv_sym x y = ()
let equiv_trans x y z = ()
let cm_identity x =
Mem.emp_unit (hp_of x);
Mem.star_commutative (hp_of x) Mem.emp
let star_commutative p1 p2 = Mem.star_commutative (hp_of p1) (hp_of p2)
let star_associative p1 p2 p3 = Mem.star_associative (hp_of p1) (hp_of p2) (hp_of p3)
let star_congruence p1 p2 p3 p4 = Mem.star_congruence (hp_of p1) (hp_of p2) (hp_of p3) (hp_of p4)
let vrefine_am (v: vprop) (p: (t_of v -> Tot prop)) : Tot (a_mem_prop (hp_of v)) =
fun h -> p (sel_of v h)
let vrefine_hp
v p
= refine_slprop (hp_of v) (vrefine_am v p)
let interp_vrefine_hp
v p m
= ()
let vrefine_sel' (v: vprop) (p: (t_of v -> Tot prop)) : Tot (selector' (vrefine_t v p) (vrefine_hp v p))
=
fun (h: Mem.hmem (vrefine_hp v p)) ->
interp_refine_slprop (hp_of v) (vrefine_am v p) h;
sel_of v h
let vrefine_sel
v p
= assert (sel_depends_only_on (vrefine_sel' v p));
assert (sel_depends_only_on_core (vrefine_sel' v p));
vrefine_sel' v p
let vrefine_sel_eq
v p m
= ()
let vdep_hp_payload
(v: vprop)
(p: (t_of v -> Tot vprop))
(h: Mem.hmem (hp_of v))
: Tot slprop
= hp_of (p (sel_of v h))
let vdep_hp
v p
=
sdep (hp_of v) (vdep_hp_payload v p) | {
"checked_file": "/",
"dependencies": [
"Steel.Semantics.Instantiate.fsti.checked",
"Steel.Semantics.Hoare.MST.fst.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.PropositionalExtensionality.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.Effect.Common.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommMonoidSimple.Equiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": false,
"full_module": "Steel.Semantics.Instantiate",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "Steel.Semantics.Hoare.MST",
"short_module": "Sem"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
v: Steel.Effect.Common.vprop ->
p: (_: Steel.Effect.Common.t_of v -> Steel.Effect.Common.vprop) ->
m: Steel.Memory.mem
-> FStar.Pervasives.Lemma
(ensures
Steel.Memory.interp (Steel.Effect.Common.vdep_hp v p) m <==>
Steel.Memory.interp (Steel.Effect.Common.hp_of v) m /\
Steel.Memory.interp (Steel.Memory.star (Steel.Effect.Common.hp_of v)
(Steel.Effect.Common.hp_of (p (Steel.Effect.Common.sel_of v m))))
m) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.t_of",
"Steel.Memory.mem",
"FStar.Classical.move_requires",
"Prims.unit",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Steel.Memory.interp_star",
"Steel.Effect.Common.hp_of",
"Steel.Effect.Common.sel_of",
"Prims.logical",
"Prims.l_and",
"Steel.Memory.interp",
"Steel.Memory.star",
"Prims.prop",
"Steel.Effect.Common.vdep_hp",
"Steel.Memory.interp_sdep",
"Steel.Effect.Common.vdep_hp_payload"
] | [] | false | false | true | false | false | let interp_vdep_hp v p m =
| interp_sdep (hp_of v) (vdep_hp_payload v p) m;
let left = interp (vdep_hp v p) m in
let right = interp (hp_of v) m /\ interp ((hp_of v) `Mem.star` (hp_of (p (sel_of v m)))) m in
let f () : Lemma (requires left) (ensures right) =
interp_star (hp_of v) (hp_of (p (sel_of v m))) m
in
let g () : Lemma (requires right) (ensures left) =
interp_star (hp_of v) (hp_of (p (sel_of v m))) m
in
Classical.move_requires f ();
Classical.move_requires g () | false |
FStar.OrdMap.fst | FStar.OrdMap.dom | val dom : #key:eqtype -> #value:Type -> #f:cmp key -> m:ordmap key value f ->
Tot (ordset key f) | val dom : #key:eqtype -> #value:Type -> #f:cmp key -> m:ordmap key value f ->
Tot (ordset key f) | let dom (#k:eqtype) (#v:Type) #f m = (Mk_map?.d m) | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 50,
"end_line": 49,
"start_col": 0,
"start_line": 49
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f
let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g
let const_on (#k:eqtype) (#v:Type) #f d x =
let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g
let select (#k:eqtype) (#v:Type) #f x m = (Mk_map?.m m) x
let insert (#a:eqtype) (#f:cmp a) (x:a) (s:ordset a f) = union #a #f (singleton #a #f x) s
let update (#k:eqtype) (#v:Type) #f x y m =
let s' = insert x (Mk_map?.d m) in
let g' = F.on_dom k (fun (x':k) -> if x' = x then Some y else (Mk_map?.m m) x') in
Mk_map s' g'
let contains (#k:eqtype) (#v:Type) #f x m = mem x (Mk_map?.d m) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m: FStar.OrdMap.ordmap key value f -> FStar.OrdSet.ordset key f | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdMap.ordmap",
"FStar.OrdMap.__proj__Mk_map__item__d",
"FStar.OrdSet.ordset"
] | [] | false | false | false | false | false | let dom (#k: eqtype) (#v: Type) #f m =
| (Mk_map?.d m) | false |
Steel.Effect.Common.fst | Steel.Effect.Common.vrewrite_sel | val vrewrite_sel (v: vprop) (#t: Type) (f: (normal (t_of v) -> GTot t)) : Tot (selector t (normal (hp_of v))) | val vrewrite_sel (v: vprop) (#t: Type) (f: (normal (t_of v) -> GTot t)) : Tot (selector t (normal (hp_of v))) | let vrewrite_sel
v #t f
=
(fun (h: Mem.hmem (normal (hp_of v))) -> f ((normal (sel_of v) <: selector' _ _) h)) | {
"file_name": "lib/steel/Steel.Effect.Common.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 86,
"end_line": 198,
"start_col": 0,
"start_line": 195
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Effect.Common
module Sem = Steel.Semantics.Hoare.MST
module Mem = Steel.Memory
open Steel.Semantics.Instantiate
module FExt = FStar.FunctionalExtensionality
let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()})
let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q)
let reveal_can_be_split () = ()
let can_be_split_interp r r' h = ()
let can_be_split_trans p q r = ()
let can_be_split_star_l p q = ()
let can_be_split_star_r p q = ()
let can_be_split_refl p = ()
let can_be_split_congr_l p q r =
Classical.forall_intro (interp_star (hp_of p) (hp_of r));
Classical.forall_intro (interp_star (hp_of q) (hp_of r))
let can_be_split_congr_r p q r =
Classical.forall_intro (interp_star (hp_of r) (hp_of p));
Classical.forall_intro (interp_star (hp_of r) (hp_of q))
let equiv (p q:vprop) : prop = Mem.equiv (hp_of p) (hp_of q) /\ True
let reveal_equiv p q = ()
let valid_rmem (#frame:vprop) (h:rmem' frame) : prop =
forall (p p1 p2:vprop). can_be_split frame p /\ p == VStar p1 p2 ==>
(h p1, h p2) == h (VStar p1 p2)
let lemma_valid_mk_rmem (r:vprop) (h:hmem r) = ()
let reveal_mk_rmem (r:vprop) (h:hmem r) (r0:vprop{r `can_be_split` r0})
: Lemma ((mk_rmem r h) r0 == sel_of r0 h)
= FExt.feq_on_domain_g (unrestricted_mk_rmem r h)
let emp':vprop' =
{ hp = emp;
t = unit;
sel = fun _ -> ()}
let emp = VUnit emp'
let reveal_emp () = ()
let lemma_valid_focus_rmem #r h r0 =
Classical.forall_intro (Classical.move_requires (can_be_split_trans r r0))
let rec lemma_frame_refl' (frame:vprop) (h0:rmem frame) (h1:rmem frame)
: Lemma ((h0 frame == h1 frame) <==> frame_equalities' frame h0 h1)
= match frame with
| VUnit _ -> ()
| VStar p1 p2 ->
can_be_split_star_l p1 p2;
can_be_split_star_r p1 p2;
let h01 : rmem p1 = focus_rmem h0 p1 in
let h11 : rmem p1 = focus_rmem h1 p1 in
let h02 = focus_rmem h0 p2 in
let h12 = focus_rmem h1 p2 in
lemma_frame_refl' p1 h01 h11;
lemma_frame_refl' p2 h02 h12
let lemma_frame_equalities frame h0 h1 p =
let p1 : prop = h0 frame == h1 frame in
let p2 : prop = frame_equalities' frame h0 h1 in
lemma_frame_refl' frame h0 h1;
FStar.PropositionalExtensionality.apply p1 p2
let lemma_frame_emp h0 h1 p =
FStar.PropositionalExtensionality.apply True (h0 (VUnit emp') == h1 (VUnit emp'))
let elim_conjunction p1 p1' p2 p2' = ()
let can_be_split_dep_refl p = ()
let equiv_can_be_split p1 p2 = ()
let intro_can_be_split_frame p q frame = ()
let can_be_split_post_elim t1 t2 = ()
let equiv_forall_refl t = ()
let equiv_forall_elim t1 t2 = ()
let equiv_refl x = ()
let equiv_sym x y = ()
let equiv_trans x y z = ()
let cm_identity x =
Mem.emp_unit (hp_of x);
Mem.star_commutative (hp_of x) Mem.emp
let star_commutative p1 p2 = Mem.star_commutative (hp_of p1) (hp_of p2)
let star_associative p1 p2 p3 = Mem.star_associative (hp_of p1) (hp_of p2) (hp_of p3)
let star_congruence p1 p2 p3 p4 = Mem.star_congruence (hp_of p1) (hp_of p2) (hp_of p3) (hp_of p4)
let vrefine_am (v: vprop) (p: (t_of v -> Tot prop)) : Tot (a_mem_prop (hp_of v)) =
fun h -> p (sel_of v h)
let vrefine_hp
v p
= refine_slprop (hp_of v) (vrefine_am v p)
let interp_vrefine_hp
v p m
= ()
let vrefine_sel' (v: vprop) (p: (t_of v -> Tot prop)) : Tot (selector' (vrefine_t v p) (vrefine_hp v p))
=
fun (h: Mem.hmem (vrefine_hp v p)) ->
interp_refine_slprop (hp_of v) (vrefine_am v p) h;
sel_of v h
let vrefine_sel
v p
= assert (sel_depends_only_on (vrefine_sel' v p));
assert (sel_depends_only_on_core (vrefine_sel' v p));
vrefine_sel' v p
let vrefine_sel_eq
v p m
= ()
let vdep_hp_payload
(v: vprop)
(p: (t_of v -> Tot vprop))
(h: Mem.hmem (hp_of v))
: Tot slprop
= hp_of (p (sel_of v h))
let vdep_hp
v p
=
sdep (hp_of v) (vdep_hp_payload v p)
let interp_vdep_hp
v p m
=
interp_sdep (hp_of v) (vdep_hp_payload v p) m;
let left = interp (vdep_hp v p) m in
let right = interp (hp_of v) m /\ interp (hp_of v `Mem.star` hp_of (p (sel_of v m))) m in
let f ()
: Lemma
(requires left)
(ensures right)
= interp_star (hp_of v) (hp_of (p (sel_of v m))) m
in
let g ()
: Lemma
(requires right)
(ensures left)
= interp_star (hp_of v) (hp_of (p (sel_of v m))) m
in
Classical.move_requires f ();
Classical.move_requires g ()
let vdep_sel'
(v: vprop)
(p: t_of v -> Tot vprop)
: Tot (selector' (vdep_t v p) (vdep_hp v p))
=
fun (m: Mem.hmem (vdep_hp v p)) ->
interp_vdep_hp v p m;
let x = sel_of v m in
let y = sel_of (p (sel_of v m)) m in
(| x, y |)
let vdep_sel
v p
= Classical.forall_intro_2 (Classical.move_requires_2 (fun (m0 m1: mem) -> (join_commutative m0) m1));
vdep_sel' v p
let vdep_sel_eq
v p m
= Classical.forall_intro_2 (Classical.move_requires_2 (fun (m0 m1: mem) -> (join_commutative m0) m1));
() | {
"checked_file": "/",
"dependencies": [
"Steel.Semantics.Instantiate.fsti.checked",
"Steel.Semantics.Hoare.MST.fst.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.PropositionalExtensionality.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.Effect.Common.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommMonoidSimple.Equiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": false,
"full_module": "Steel.Semantics.Instantiate",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "Steel.Semantics.Hoare.MST",
"short_module": "Sem"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
v: Steel.Effect.Common.vprop ->
f: (_: Steel.Effect.Common.normal (Steel.Effect.Common.t_of v) -> Prims.GTot t)
-> Steel.Effect.Common.selector t (Steel.Effect.Common.normal (Steel.Effect.Common.hp_of v)) | Prims.Tot | [
"total"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.normal",
"Steel.Effect.Common.t_of",
"Steel.Memory.hmem",
"Steel.Memory.slprop",
"Steel.Effect.Common.hp_of",
"Steel.Effect.Common.selector'",
"Steel.Effect.Common.sel_of"
] | [] | false | false | false | false | false | let vrewrite_sel v #t f =
| (fun (h: Mem.hmem (normal (hp_of v))) -> f ((normal (sel_of v) <: selector' _ _) h)) | false |
FStar.OrdMap.fst | FStar.OrdMap.remove | val remove : #key:eqtype -> #value:Type -> #f:cmp key -> key
-> ordmap key value f -> Tot (ordmap key value f) | val remove : #key:eqtype -> #value:Type -> #f:cmp key -> key
-> ordmap key value f -> Tot (ordmap key value f) | let remove (#k:eqtype) (#v:Type) #f x m =
let s' = remove x (Mk_map?.d m) in
let g' = F.on_dom k (fun x' -> if x' = x then None else (Mk_map?.m m) x') in
Mk_map s' g' | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 54,
"start_col": 0,
"start_line": 51
} | (*
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.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f
let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g
let const_on (#k:eqtype) (#v:Type) #f d x =
let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g
let select (#k:eqtype) (#v:Type) #f x m = (Mk_map?.m m) x
let insert (#a:eqtype) (#f:cmp a) (x:a) (s:ordset a f) = union #a #f (singleton #a #f x) s
let update (#k:eqtype) (#v:Type) #f x y m =
let s' = insert x (Mk_map?.d m) in
let g' = F.on_dom k (fun (x':k) -> if x' = x then Some y else (Mk_map?.m m) x') in
Mk_map s' g'
let contains (#k:eqtype) (#v:Type) #f x m = mem x (Mk_map?.d m)
let dom (#k:eqtype) (#v:Type) #f m = (Mk_map?.d m) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: key -> m: FStar.OrdMap.ordmap key value f -> FStar.OrdMap.ordmap key value f | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdMap.ordmap",
"FStar.OrdMap.Mk_map",
"FStar.FunctionalExtensionality.restricted_t",
"FStar.Pervasives.Native.option",
"FStar.FunctionalExtensionality.on_dom",
"Prims.op_Equality",
"FStar.Pervasives.Native.None",
"Prims.bool",
"FStar.OrdMap.__proj__Mk_map__item__m",
"FStar.OrdSet.ordset",
"FStar.OrdSet.remove",
"FStar.OrdMap.__proj__Mk_map__item__d"
] | [] | false | false | false | false | false | let remove (#k: eqtype) (#v: Type) #f x m =
| let s' = remove x (Mk_map?.d m) in
let g' = F.on_dom k (fun x' -> if x' = x then None else (Mk_map?.m m) x') in
Mk_map s' g' | false |
FStar.OrdMap.fst | FStar.OrdMap.update | val update : #key:eqtype -> #value:Type -> #f:cmp key -> key -> value
-> m:ordmap key value f -> Tot (ordmap key value f) | val update : #key:eqtype -> #value:Type -> #f:cmp key -> key -> value
-> m:ordmap key value f -> Tot (ordmap key value f) | let update (#k:eqtype) (#v:Type) #f x y m =
let s' = insert x (Mk_map?.d m) in
let g' = F.on_dom k (fun (x':k) -> if x' = x then Some y else (Mk_map?.m m) x') in
Mk_map s' g' | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 45,
"start_col": 0,
"start_line": 42
} | (*
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.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f
let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g
let const_on (#k:eqtype) (#v:Type) #f d x =
let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g
let select (#k:eqtype) (#v:Type) #f x m = (Mk_map?.m m) x
let insert (#a:eqtype) (#f:cmp a) (x:a) (s:ordset a f) = union #a #f (singleton #a #f x) s | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: key -> y: value -> m: FStar.OrdMap.ordmap key value f -> FStar.OrdMap.ordmap key value f | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdMap.ordmap",
"FStar.OrdMap.Mk_map",
"FStar.FunctionalExtensionality.restricted_t",
"FStar.Pervasives.Native.option",
"FStar.FunctionalExtensionality.on_dom",
"Prims.op_Equality",
"FStar.Pervasives.Native.Some",
"Prims.bool",
"FStar.OrdMap.__proj__Mk_map__item__m",
"FStar.OrdSet.ordset",
"FStar.OrdMap.insert",
"FStar.OrdMap.__proj__Mk_map__item__d"
] | [] | false | false | false | false | false | let update (#k: eqtype) (#v: Type) #f x y m =
| let s' = insert x (Mk_map?.d m) in
let g' = F.on_dom k (fun (x': k) -> if x' = x then Some y else (Mk_map?.m m) x') in
Mk_map s' g' | false |
Steel.Effect.Common.fst | Steel.Effect.Common.emp_unit_variant | val emp_unit_variant (p:vprop) : Lemma
(ensures can_be_split p (p `star` emp)) | val emp_unit_variant (p:vprop) : Lemma
(ensures can_be_split p (p `star` emp)) | let emp_unit_variant p = Mem.emp_unit (hp_of p) | {
"file_name": "lib/steel/Steel.Effect.Common.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 47,
"end_line": 207,
"start_col": 0,
"start_line": 207
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Effect.Common
module Sem = Steel.Semantics.Hoare.MST
module Mem = Steel.Memory
open Steel.Semantics.Instantiate
module FExt = FStar.FunctionalExtensionality
let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()})
let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q)
let reveal_can_be_split () = ()
let can_be_split_interp r r' h = ()
let can_be_split_trans p q r = ()
let can_be_split_star_l p q = ()
let can_be_split_star_r p q = ()
let can_be_split_refl p = ()
let can_be_split_congr_l p q r =
Classical.forall_intro (interp_star (hp_of p) (hp_of r));
Classical.forall_intro (interp_star (hp_of q) (hp_of r))
let can_be_split_congr_r p q r =
Classical.forall_intro (interp_star (hp_of r) (hp_of p));
Classical.forall_intro (interp_star (hp_of r) (hp_of q))
let equiv (p q:vprop) : prop = Mem.equiv (hp_of p) (hp_of q) /\ True
let reveal_equiv p q = ()
let valid_rmem (#frame:vprop) (h:rmem' frame) : prop =
forall (p p1 p2:vprop). can_be_split frame p /\ p == VStar p1 p2 ==>
(h p1, h p2) == h (VStar p1 p2)
let lemma_valid_mk_rmem (r:vprop) (h:hmem r) = ()
let reveal_mk_rmem (r:vprop) (h:hmem r) (r0:vprop{r `can_be_split` r0})
: Lemma ((mk_rmem r h) r0 == sel_of r0 h)
= FExt.feq_on_domain_g (unrestricted_mk_rmem r h)
let emp':vprop' =
{ hp = emp;
t = unit;
sel = fun _ -> ()}
let emp = VUnit emp'
let reveal_emp () = ()
let lemma_valid_focus_rmem #r h r0 =
Classical.forall_intro (Classical.move_requires (can_be_split_trans r r0))
let rec lemma_frame_refl' (frame:vprop) (h0:rmem frame) (h1:rmem frame)
: Lemma ((h0 frame == h1 frame) <==> frame_equalities' frame h0 h1)
= match frame with
| VUnit _ -> ()
| VStar p1 p2 ->
can_be_split_star_l p1 p2;
can_be_split_star_r p1 p2;
let h01 : rmem p1 = focus_rmem h0 p1 in
let h11 : rmem p1 = focus_rmem h1 p1 in
let h02 = focus_rmem h0 p2 in
let h12 = focus_rmem h1 p2 in
lemma_frame_refl' p1 h01 h11;
lemma_frame_refl' p2 h02 h12
let lemma_frame_equalities frame h0 h1 p =
let p1 : prop = h0 frame == h1 frame in
let p2 : prop = frame_equalities' frame h0 h1 in
lemma_frame_refl' frame h0 h1;
FStar.PropositionalExtensionality.apply p1 p2
let lemma_frame_emp h0 h1 p =
FStar.PropositionalExtensionality.apply True (h0 (VUnit emp') == h1 (VUnit emp'))
let elim_conjunction p1 p1' p2 p2' = ()
let can_be_split_dep_refl p = ()
let equiv_can_be_split p1 p2 = ()
let intro_can_be_split_frame p q frame = ()
let can_be_split_post_elim t1 t2 = ()
let equiv_forall_refl t = ()
let equiv_forall_elim t1 t2 = ()
let equiv_refl x = ()
let equiv_sym x y = ()
let equiv_trans x y z = ()
let cm_identity x =
Mem.emp_unit (hp_of x);
Mem.star_commutative (hp_of x) Mem.emp
let star_commutative p1 p2 = Mem.star_commutative (hp_of p1) (hp_of p2)
let star_associative p1 p2 p3 = Mem.star_associative (hp_of p1) (hp_of p2) (hp_of p3)
let star_congruence p1 p2 p3 p4 = Mem.star_congruence (hp_of p1) (hp_of p2) (hp_of p3) (hp_of p4)
let vrefine_am (v: vprop) (p: (t_of v -> Tot prop)) : Tot (a_mem_prop (hp_of v)) =
fun h -> p (sel_of v h)
let vrefine_hp
v p
= refine_slprop (hp_of v) (vrefine_am v p)
let interp_vrefine_hp
v p m
= ()
let vrefine_sel' (v: vprop) (p: (t_of v -> Tot prop)) : Tot (selector' (vrefine_t v p) (vrefine_hp v p))
=
fun (h: Mem.hmem (vrefine_hp v p)) ->
interp_refine_slprop (hp_of v) (vrefine_am v p) h;
sel_of v h
let vrefine_sel
v p
= assert (sel_depends_only_on (vrefine_sel' v p));
assert (sel_depends_only_on_core (vrefine_sel' v p));
vrefine_sel' v p
let vrefine_sel_eq
v p m
= ()
let vdep_hp_payload
(v: vprop)
(p: (t_of v -> Tot vprop))
(h: Mem.hmem (hp_of v))
: Tot slprop
= hp_of (p (sel_of v h))
let vdep_hp
v p
=
sdep (hp_of v) (vdep_hp_payload v p)
let interp_vdep_hp
v p m
=
interp_sdep (hp_of v) (vdep_hp_payload v p) m;
let left = interp (vdep_hp v p) m in
let right = interp (hp_of v) m /\ interp (hp_of v `Mem.star` hp_of (p (sel_of v m))) m in
let f ()
: Lemma
(requires left)
(ensures right)
= interp_star (hp_of v) (hp_of (p (sel_of v m))) m
in
let g ()
: Lemma
(requires right)
(ensures left)
= interp_star (hp_of v) (hp_of (p (sel_of v m))) m
in
Classical.move_requires f ();
Classical.move_requires g ()
let vdep_sel'
(v: vprop)
(p: t_of v -> Tot vprop)
: Tot (selector' (vdep_t v p) (vdep_hp v p))
=
fun (m: Mem.hmem (vdep_hp v p)) ->
interp_vdep_hp v p m;
let x = sel_of v m in
let y = sel_of (p (sel_of v m)) m in
(| x, y |)
let vdep_sel
v p
= Classical.forall_intro_2 (Classical.move_requires_2 (fun (m0 m1: mem) -> (join_commutative m0) m1));
vdep_sel' v p
let vdep_sel_eq
v p m
= Classical.forall_intro_2 (Classical.move_requires_2 (fun (m0 m1: mem) -> (join_commutative m0) m1));
()
let vrewrite_sel
v #t f
=
(fun (h: Mem.hmem (normal (hp_of v))) -> f ((normal (sel_of v) <: selector' _ _) h))
let vrewrite_sel_eq
v #t f h
= ()
let solve_can_be_split_for _ = ()
let solve_can_be_split_lookup = () | {
"checked_file": "/",
"dependencies": [
"Steel.Semantics.Instantiate.fsti.checked",
"Steel.Semantics.Hoare.MST.fst.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.PropositionalExtensionality.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.Effect.Common.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Derived.Lemmas",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommMonoidSimple.Equiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": false,
"full_module": "Steel.Semantics.Instantiate",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "Steel.Semantics.Hoare.MST",
"short_module": "Sem"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Steel.Effect.Common.vprop
-> FStar.Pervasives.Lemma
(ensures Steel.Effect.Common.can_be_split p (Steel.Effect.Common.star p Steel.Effect.Common.emp)
) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Memory.emp_unit",
"Steel.Effect.Common.hp_of",
"Prims.unit"
] | [] | true | false | true | false | false | let emp_unit_variant p =
| Mem.emp_unit (hp_of p) | false |
Steel.Effect.Common.fst | Steel.Effect.Common.vdep_sel_eq | val vdep_sel_eq (v: vprop) (p: ( (t_of v) -> Tot vprop)) (m: Mem.hmem (vdep_hp v p)) : Lemma
(
interp (hp_of v) m /\
begin let x = sel_of v m in
interp (hp_of (p x)) m /\
vdep_sel v p m == (| x, sel_of (p x) m |)
end
) | val vdep_sel_eq (v: vprop) (p: ( (t_of v) -> Tot vprop)) (m: Mem.hmem (vdep_hp v p)) : Lemma
(
interp (hp_of v) m /\
begin let x = sel_of v m in
interp (hp_of (p x)) m /\
vdep_sel v p m == (| x, sel_of (p x) m |)
end
) | let vdep_sel_eq
v p m
= Classical.forall_intro_2 (Classical.move_requires_2 (fun (m0 m1: mem) -> (join_commutative m0) m1));
() | {
"file_name": "lib/steel/Steel.Effect.Common.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 4,
"end_line": 193,
"start_col": 0,
"start_line": 190
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Effect.Common
module Sem = Steel.Semantics.Hoare.MST
module Mem = Steel.Memory
open Steel.Semantics.Instantiate
module FExt = FStar.FunctionalExtensionality
let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()})
let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q)
let reveal_can_be_split () = ()
let can_be_split_interp r r' h = ()
let can_be_split_trans p q r = ()
let can_be_split_star_l p q = ()
let can_be_split_star_r p q = ()
let can_be_split_refl p = ()
let can_be_split_congr_l p q r =
Classical.forall_intro (interp_star (hp_of p) (hp_of r));
Classical.forall_intro (interp_star (hp_of q) (hp_of r))
let can_be_split_congr_r p q r =
Classical.forall_intro (interp_star (hp_of r) (hp_of p));
Classical.forall_intro (interp_star (hp_of r) (hp_of q))
let equiv (p q:vprop) : prop = Mem.equiv (hp_of p) (hp_of q) /\ True
let reveal_equiv p q = ()
let valid_rmem (#frame:vprop) (h:rmem' frame) : prop =
forall (p p1 p2:vprop). can_be_split frame p /\ p == VStar p1 p2 ==>
(h p1, h p2) == h (VStar p1 p2)
let lemma_valid_mk_rmem (r:vprop) (h:hmem r) = ()
let reveal_mk_rmem (r:vprop) (h:hmem r) (r0:vprop{r `can_be_split` r0})
: Lemma ((mk_rmem r h) r0 == sel_of r0 h)
= FExt.feq_on_domain_g (unrestricted_mk_rmem r h)
let emp':vprop' =
{ hp = emp;
t = unit;
sel = fun _ -> ()}
let emp = VUnit emp'
let reveal_emp () = ()
let lemma_valid_focus_rmem #r h r0 =
Classical.forall_intro (Classical.move_requires (can_be_split_trans r r0))
let rec lemma_frame_refl' (frame:vprop) (h0:rmem frame) (h1:rmem frame)
: Lemma ((h0 frame == h1 frame) <==> frame_equalities' frame h0 h1)
= match frame with
| VUnit _ -> ()
| VStar p1 p2 ->
can_be_split_star_l p1 p2;
can_be_split_star_r p1 p2;
let h01 : rmem p1 = focus_rmem h0 p1 in
let h11 : rmem p1 = focus_rmem h1 p1 in
let h02 = focus_rmem h0 p2 in
let h12 = focus_rmem h1 p2 in
lemma_frame_refl' p1 h01 h11;
lemma_frame_refl' p2 h02 h12
let lemma_frame_equalities frame h0 h1 p =
let p1 : prop = h0 frame == h1 frame in
let p2 : prop = frame_equalities' frame h0 h1 in
lemma_frame_refl' frame h0 h1;
FStar.PropositionalExtensionality.apply p1 p2
let lemma_frame_emp h0 h1 p =
FStar.PropositionalExtensionality.apply True (h0 (VUnit emp') == h1 (VUnit emp'))
let elim_conjunction p1 p1' p2 p2' = ()
let can_be_split_dep_refl p = ()
let equiv_can_be_split p1 p2 = ()
let intro_can_be_split_frame p q frame = ()
let can_be_split_post_elim t1 t2 = ()
let equiv_forall_refl t = ()
let equiv_forall_elim t1 t2 = ()
let equiv_refl x = ()
let equiv_sym x y = ()
let equiv_trans x y z = ()
let cm_identity x =
Mem.emp_unit (hp_of x);
Mem.star_commutative (hp_of x) Mem.emp
let star_commutative p1 p2 = Mem.star_commutative (hp_of p1) (hp_of p2)
let star_associative p1 p2 p3 = Mem.star_associative (hp_of p1) (hp_of p2) (hp_of p3)
let star_congruence p1 p2 p3 p4 = Mem.star_congruence (hp_of p1) (hp_of p2) (hp_of p3) (hp_of p4)
let vrefine_am (v: vprop) (p: (t_of v -> Tot prop)) : Tot (a_mem_prop (hp_of v)) =
fun h -> p (sel_of v h)
let vrefine_hp
v p
= refine_slprop (hp_of v) (vrefine_am v p)
let interp_vrefine_hp
v p m
= ()
let vrefine_sel' (v: vprop) (p: (t_of v -> Tot prop)) : Tot (selector' (vrefine_t v p) (vrefine_hp v p))
=
fun (h: Mem.hmem (vrefine_hp v p)) ->
interp_refine_slprop (hp_of v) (vrefine_am v p) h;
sel_of v h
let vrefine_sel
v p
= assert (sel_depends_only_on (vrefine_sel' v p));
assert (sel_depends_only_on_core (vrefine_sel' v p));
vrefine_sel' v p
let vrefine_sel_eq
v p m
= ()
let vdep_hp_payload
(v: vprop)
(p: (t_of v -> Tot vprop))
(h: Mem.hmem (hp_of v))
: Tot slprop
= hp_of (p (sel_of v h))
let vdep_hp
v p
=
sdep (hp_of v) (vdep_hp_payload v p)
let interp_vdep_hp
v p m
=
interp_sdep (hp_of v) (vdep_hp_payload v p) m;
let left = interp (vdep_hp v p) m in
let right = interp (hp_of v) m /\ interp (hp_of v `Mem.star` hp_of (p (sel_of v m))) m in
let f ()
: Lemma
(requires left)
(ensures right)
= interp_star (hp_of v) (hp_of (p (sel_of v m))) m
in
let g ()
: Lemma
(requires right)
(ensures left)
= interp_star (hp_of v) (hp_of (p (sel_of v m))) m
in
Classical.move_requires f ();
Classical.move_requires g ()
let vdep_sel'
(v: vprop)
(p: t_of v -> Tot vprop)
: Tot (selector' (vdep_t v p) (vdep_hp v p))
=
fun (m: Mem.hmem (vdep_hp v p)) ->
interp_vdep_hp v p m;
let x = sel_of v m in
let y = sel_of (p (sel_of v m)) m in
(| x, y |)
let vdep_sel
v p
= Classical.forall_intro_2 (Classical.move_requires_2 (fun (m0 m1: mem) -> (join_commutative m0) m1));
vdep_sel' v p | {
"checked_file": "/",
"dependencies": [
"Steel.Semantics.Instantiate.fsti.checked",
"Steel.Semantics.Hoare.MST.fst.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.PropositionalExtensionality.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.Effect.Common.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommMonoidSimple.Equiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": false,
"full_module": "Steel.Semantics.Instantiate",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "Steel.Semantics.Hoare.MST",
"short_module": "Sem"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
v: Steel.Effect.Common.vprop ->
p: (_: Steel.Effect.Common.t_of v -> Steel.Effect.Common.vprop) ->
m: Steel.Memory.hmem (Steel.Effect.Common.vdep_hp v p)
-> FStar.Pervasives.Lemma
(ensures
Steel.Memory.interp (Steel.Effect.Common.hp_of v) m /\
(let x = Steel.Effect.Common.sel_of v m in
Steel.Memory.interp (Steel.Effect.Common.hp_of (p x)) m /\
Steel.Effect.Common.vdep_sel v p m == (| x, Steel.Effect.Common.sel_of (p x) m |))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.t_of",
"Steel.Memory.hmem",
"Steel.Effect.Common.vdep_hp",
"Prims.unit",
"FStar.Classical.forall_intro_2",
"Steel.Memory.mem",
"Prims.l_imp",
"Steel.Memory.disjoint",
"Prims.l_and",
"Prims.eq2",
"Steel.Memory.join",
"FStar.Classical.move_requires_2",
"Steel.Memory.join_commutative"
] | [] | false | false | true | false | false | let vdep_sel_eq v p m =
| Classical.forall_intro_2 (Classical.move_requires_2 (fun (m0: mem) (m1: mem) ->
(join_commutative m0) m1));
() | false |
FStar.OrdMap.fst | FStar.OrdMap.choose | val choose : #key:eqtype -> #value:Type -> #f:cmp key -> ordmap key value f
-> Tot (option (key * value)) | val choose : #key:eqtype -> #value:Type -> #f:cmp key -> ordmap key value f
-> Tot (option (key * value)) | let choose (#k:eqtype) (#v:Type) #f m =
match OrdSet.choose (Mk_map?.d m) with
| None -> None
| Some x -> Some (x, Some?.v ((Mk_map?.m m) x)) | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 51,
"end_line": 59,
"start_col": 0,
"start_line": 56
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f
let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g
let const_on (#k:eqtype) (#v:Type) #f d x =
let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g
let select (#k:eqtype) (#v:Type) #f x m = (Mk_map?.m m) x
let insert (#a:eqtype) (#f:cmp a) (x:a) (s:ordset a f) = union #a #f (singleton #a #f x) s
let update (#k:eqtype) (#v:Type) #f x y m =
let s' = insert x (Mk_map?.d m) in
let g' = F.on_dom k (fun (x':k) -> if x' = x then Some y else (Mk_map?.m m) x') in
Mk_map s' g'
let contains (#k:eqtype) (#v:Type) #f x m = mem x (Mk_map?.d m)
let dom (#k:eqtype) (#v:Type) #f m = (Mk_map?.d m)
let remove (#k:eqtype) (#v:Type) #f x m =
let s' = remove x (Mk_map?.d m) in
let g' = F.on_dom k (fun x' -> if x' = x then None else (Mk_map?.m m) x') in
Mk_map s' g' | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m: FStar.OrdMap.ordmap key value f -> FStar.Pervasives.Native.option (key * value) | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdMap.ordmap",
"FStar.OrdSet.choose",
"FStar.OrdMap.__proj__Mk_map__item__d",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.__proj__Some__item__v",
"FStar.OrdMap.__proj__Mk_map__item__m",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | false | false | let choose (#k: eqtype) (#v: Type) #f m =
| match OrdSet.choose (Mk_map?.d m) with
| None -> None
| Some x -> Some (x, Some?.v ((Mk_map?.m m) x)) | false |
FStar.OrdMap.fst | FStar.OrdMap.size | val size : #key:eqtype -> #value:Type -> #f:cmp key -> ordmap key value f
-> Tot nat | val size : #key:eqtype -> #value:Type -> #f:cmp key -> ordmap key value f
-> Tot nat | let size (#k:eqtype) (#v:Type) #f m = OrdSet.size (Mk_map?.d m) | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 63,
"end_line": 61,
"start_col": 0,
"start_line": 61
} | (*
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.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f
let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g
let const_on (#k:eqtype) (#v:Type) #f d x =
let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g
let select (#k:eqtype) (#v:Type) #f x m = (Mk_map?.m m) x
let insert (#a:eqtype) (#f:cmp a) (x:a) (s:ordset a f) = union #a #f (singleton #a #f x) s
let update (#k:eqtype) (#v:Type) #f x y m =
let s' = insert x (Mk_map?.d m) in
let g' = F.on_dom k (fun (x':k) -> if x' = x then Some y else (Mk_map?.m m) x') in
Mk_map s' g'
let contains (#k:eqtype) (#v:Type) #f x m = mem x (Mk_map?.d m)
let dom (#k:eqtype) (#v:Type) #f m = (Mk_map?.d m)
let remove (#k:eqtype) (#v:Type) #f x m =
let s' = remove x (Mk_map?.d m) in
let g' = F.on_dom k (fun x' -> if x' = x then None else (Mk_map?.m m) x') in
Mk_map s' g'
let choose (#k:eqtype) (#v:Type) #f m =
match OrdSet.choose (Mk_map?.d m) with
| None -> None
| Some x -> Some (x, Some?.v ((Mk_map?.m m) x)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m: FStar.OrdMap.ordmap key value f -> Prims.nat | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdMap.ordmap",
"FStar.OrdSet.size",
"FStar.OrdMap.__proj__Mk_map__item__d",
"Prims.nat"
] | [] | false | false | false | false | false | let size (#k: eqtype) (#v: Type) #f m =
| OrdSet.size (Mk_map?.d m) | false |
LList2.fst | LList2.pllist_get | val pllist_get (#l: Ghost.erased (list U32.t)) (p: ref (scalar (ptr cell)))
: STT (ptr cell)
(pllist p l)
(fun pc -> (pts_to p (mk_scalar (Ghost.reveal pc))) `star` (llist pc l)) | val pllist_get (#l: Ghost.erased (list U32.t)) (p: ref (scalar (ptr cell)))
: STT (ptr cell)
(pllist p l)
(fun pc -> (pts_to p (mk_scalar (Ghost.reveal pc))) `star` (llist pc l)) | let pllist_get
(#l: Ghost.erased (list U32.t))
(p: ref (scalar (ptr cell)))
: STT (ptr cell)
(pllist p l)
(fun pc -> pts_to p (mk_scalar (Ghost.reveal pc)) `star` llist pc l)
= rewrite (pllist p l) (pllist0 p l);
let _ = gen_elim () in
let pc = read p in
vpattern_rewrite (fun x -> llist x l) pc;
return pc | {
"file_name": "share/steel/examples/steelc/LList2.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 11,
"end_line": 116,
"start_col": 0,
"start_line": 106
} | module LList2
open Steel.ST.GenElim
open Steel.ST.C.Types
open Steel.ST.C.Types.Struct.Aux
open Steel.ST.C.Types.UserStruct // hides Struct
module U32 = FStar.UInt32
noeq
type cell_t = {
hd: scalar_t U32.t;
tl: scalar_t (ptr_gen cell_t);
}
noextract
inline_for_extraction
[@@ norm_field_attr]
let cell_struct_def : struct_def cell_t =
let fields = FStar.Set.add "hd" (FStar.Set.singleton "tl") in
let field_desc : field_description_gen_t (field_t fields) = {
fd_nonempty = nonempty_set_nonempty_type "hd" fields;
fd_type = (fun (n: field_t fields) -> match n with "hd" -> scalar_t U32.t | "tl" -> scalar_t (ptr_gen cell_t));
fd_typedef = (fun (n: field_t fields) -> match n with "hd" -> scalar U32.t | "tl" -> scalar (ptr_gen cell_t));
}
in {
fields = fields;
field_desc = field_desc;
mk = (fun f -> Mkcell_t (f "hd") (f "tl"));
get = (fun x (f: field_t fields) -> match f with "hd" -> x.hd | "tl" -> x.tl);
get_mk = (fun _ _ -> ());
extensionality = (fun s1 s2 phi -> phi "hd"; phi "tl");
}
noextract
inline_for_extraction
[@@ norm_field_attr]
let cell = struct_typedef cell_struct_def
[@@__reduce__]
let llist_nil (p: ptr cell) : Tot vprop =
pure (p == null _)
[@@__reduce__]
let llist_cons (p: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) (llist: (ptr cell -> (l: Ghost.erased (list U32.t) { List.Tot.length l < List.Tot.length (a :: q) }) -> Tot vprop)) : Tot vprop =
exists_ (fun (p1: ref cell) -> exists_ (fun (p2: ptr cell) ->
pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar p2 }) `star`
llist p2 q `star`
freeable p1 `star`
pure (p == p1)
))
let rec llist (p: ptr cell) (l: Ghost.erased (list U32.t)) : Tot vprop (decreases (List.Tot.length l)) =
match Ghost.reveal l with
| [] -> llist_nil p
| a :: q -> llist_cons p a q llist
let intro_llist_cons
(#opened: _)
(p1: ref cell) (#v1: Ghost.erased (typeof cell)) (p2: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t))
: STGhost unit opened
(pts_to p1 v1 `star`
llist p2 q `star`
freeable p1
)
(fun _ -> llist p1 (a :: q))
(Ghost.reveal v1 == ({ hd = mk_scalar a; tl = mk_scalar p2 }))
(fun _ -> True)
= noop ();
rewrite_with_tactic (llist_cons p1 a q llist) (llist p1 (a :: q))
let elim_llist_cons
(#opened: _)
(p1: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t))
: STGhostT (p2: Ghost.erased (ptr cell) { ~ (p1 == null _) }) opened
(llist p1 (a :: q))
(fun p2 ->
pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar (Ghost.reveal p2) }) `star`
llist p2 q `star`
freeable p1
)
= rewrite_with_tactic (llist p1 (a :: q)) (llist_cons p1 a q llist);
let _ = gen_elim () in
let p2' = vpattern_erased (fun x -> llist x q) in
let p2 : (p2: Ghost.erased (ptr cell) { ~ (p1 == null _) }) = p2' in
vpattern_rewrite (fun x -> llist x q) p2;
rewrite (pts_to _ _) (pts_to _ _);
rewrite (freeable _) (freeable _);
_
[@@__reduce__]
let pllist0
(p: ref (scalar (ptr cell)))
(l: Ghost.erased (list U32.t))
: Tot vprop
= exists_ (fun (pc: ptr cell) ->
pts_to p (mk_scalar pc) `star`
llist pc l
)
let pllist
(p: ref (scalar (ptr cell)))
(l: Ghost.erased (list U32.t))
: Tot vprop
= pllist0 p l | {
"checked_file": "/",
"dependencies": [
"Steel.ST.GenElim.fsti.checked",
"Steel.ST.C.Types.UserStruct.fsti.checked",
"Steel.ST.C.Types.Struct.Aux.fsti.checked",
"Steel.ST.C.Types.fst.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LList2.fst"
} | [
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct // hides Struct",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.Struct.Aux",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p:
Steel.ST.C.Types.Base.ref (Steel.ST.C.Types.Scalar.scalar (Steel.ST.C.Types.Base.ptr LList2.cell
))
-> Steel.ST.Effect.STT (Steel.ST.C.Types.Base.ptr LList2.cell) | Steel.ST.Effect.STT | [] | [] | [
"FStar.Ghost.erased",
"Prims.list",
"FStar.UInt32.t",
"Steel.ST.C.Types.Base.ref",
"Steel.ST.C.Types.Scalar.scalar_t",
"Steel.ST.C.Types.Base.ptr",
"LList2.cell_t",
"LList2.cell",
"Steel.ST.C.Types.Scalar.scalar",
"Steel.ST.Util.return",
"FStar.Ghost.hide",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.empty",
"Steel.Effect.Common.VStar",
"LList2.llist",
"Steel.ST.C.Types.Base.pts_to",
"Steel.ST.C.Types.Scalar.mk_scalar",
"Steel.Effect.Common.vprop",
"Prims.unit",
"Steel.ST.Util.vpattern_rewrite",
"FStar.Ghost.reveal",
"Steel.ST.C.Types.Scalar.read",
"Steel.ST.GenElim.gen_elim",
"Steel.ST.Util.exists_",
"Prims.l_True",
"Prims.prop",
"Steel.ST.Util.rewrite",
"LList2.pllist",
"LList2.pllist0",
"Steel.Effect.Common.star"
] | [] | false | true | false | false | false | let pllist_get (#l: Ghost.erased (list U32.t)) (p: ref (scalar (ptr cell)))
: STT (ptr cell)
(pllist p l)
(fun pc -> (pts_to p (mk_scalar (Ghost.reveal pc))) `star` (llist pc l)) =
| rewrite (pllist p l) (pllist0 p l);
let _ = gen_elim () in
let pc = read p in
vpattern_rewrite (fun x -> llist x l) pc;
return pc | false |
FStar.OrdMap.fst | FStar.OrdMap.eq_lemma | val eq_lemma: #k:eqtype -> #v:Type -> #f:cmp k -> m1:ordmap k v f -> m2:ordmap k v f
-> Lemma (requires (equal m1 m2))
(ensures (m1 == m2))
[SMTPat (equal m1 m2)] | val eq_lemma: #k:eqtype -> #v:Type -> #f:cmp k -> m1:ordmap k v f -> m2:ordmap k v f
-> Lemma (requires (equal m1 m2))
(ensures (m1 == m2))
[SMTPat (equal m1 m2)] | let eq_lemma (#k:eqtype) (#v:Type) #f m1 m2 =
let Mk_map s1 g1 = m1 in
let Mk_map s2 g2 = m2 in
let _ = cut (feq g1 g2) in
let _ = OrdSet.eq_lemma s1 s2 in
() | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 4,
"end_line": 73,
"start_col": 0,
"start_line": 68
} | (*
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.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f
let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g
let const_on (#k:eqtype) (#v:Type) #f d x =
let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g
let select (#k:eqtype) (#v:Type) #f x m = (Mk_map?.m m) x
let insert (#a:eqtype) (#f:cmp a) (x:a) (s:ordset a f) = union #a #f (singleton #a #f x) s
let update (#k:eqtype) (#v:Type) #f x y m =
let s' = insert x (Mk_map?.d m) in
let g' = F.on_dom k (fun (x':k) -> if x' = x then Some y else (Mk_map?.m m) x') in
Mk_map s' g'
let contains (#k:eqtype) (#v:Type) #f x m = mem x (Mk_map?.d m)
let dom (#k:eqtype) (#v:Type) #f m = (Mk_map?.d m)
let remove (#k:eqtype) (#v:Type) #f x m =
let s' = remove x (Mk_map?.d m) in
let g' = F.on_dom k (fun x' -> if x' = x then None else (Mk_map?.m m) x') in
Mk_map s' g'
let choose (#k:eqtype) (#v:Type) #f m =
match OrdSet.choose (Mk_map?.d m) with
| None -> None
| Some x -> Some (x, Some?.v ((Mk_map?.m m) x))
let size (#k:eqtype) (#v:Type) #f m = OrdSet.size (Mk_map?.d m)
let equal (#k:eqtype) (#v:Type) (#f:cmp k) (m1:ordmap k v f) (m2:ordmap k v f) =
forall x. select #k #v #f x m1 == select #k #v #f x m2
let eq_intro (#k:eqtype) (#v:Type) #f m1 m2 = () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m1: FStar.OrdMap.ordmap k v f -> m2: FStar.OrdMap.ordmap k v f
-> FStar.Pervasives.Lemma (requires FStar.OrdMap.equal m1 m2)
(ensures m1 == m2)
[SMTPat (FStar.OrdMap.equal m1 m2)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdMap.ordmap",
"FStar.OrdSet.ordset",
"FStar.OrdMap.map_t",
"Prims.unit",
"FStar.OrdSet.eq_lemma",
"Prims.cut",
"FStar.FunctionalExtensionality.feq",
"FStar.Pervasives.Native.option"
] | [] | false | false | true | false | false | let eq_lemma (#k: eqtype) (#v: Type) #f m1 m2 =
| let Mk_map s1 g1 = m1 in
let Mk_map s2 g2 = m2 in
let _ = cut (feq g1 g2) in
let _ = OrdSet.eq_lemma s1 s2 in
() | false |
FStar.OrdMap.fst | FStar.OrdMap.equal | val equal (#k:eqtype) (#v:Type) (#f:cmp k) (m1:ordmap k v f) (m2:ordmap k v f) : prop | val equal (#k:eqtype) (#v:Type) (#f:cmp k) (m1:ordmap k v f) (m2:ordmap k v f) : prop | let equal (#k:eqtype) (#v:Type) (#f:cmp k) (m1:ordmap k v f) (m2:ordmap k v f) =
forall x. select #k #v #f x m1 == select #k #v #f x m2 | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 56,
"end_line": 64,
"start_col": 0,
"start_line": 63
} | (*
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.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f
let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g
let const_on (#k:eqtype) (#v:Type) #f d x =
let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g
let select (#k:eqtype) (#v:Type) #f x m = (Mk_map?.m m) x
let insert (#a:eqtype) (#f:cmp a) (x:a) (s:ordset a f) = union #a #f (singleton #a #f x) s
let update (#k:eqtype) (#v:Type) #f x y m =
let s' = insert x (Mk_map?.d m) in
let g' = F.on_dom k (fun (x':k) -> if x' = x then Some y else (Mk_map?.m m) x') in
Mk_map s' g'
let contains (#k:eqtype) (#v:Type) #f x m = mem x (Mk_map?.d m)
let dom (#k:eqtype) (#v:Type) #f m = (Mk_map?.d m)
let remove (#k:eqtype) (#v:Type) #f x m =
let s' = remove x (Mk_map?.d m) in
let g' = F.on_dom k (fun x' -> if x' = x then None else (Mk_map?.m m) x') in
Mk_map s' g'
let choose (#k:eqtype) (#v:Type) #f m =
match OrdSet.choose (Mk_map?.d m) with
| None -> None
| Some x -> Some (x, Some?.v ((Mk_map?.m m) x))
let size (#k:eqtype) (#v:Type) #f m = OrdSet.size (Mk_map?.d m) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m1: FStar.OrdMap.ordmap k v f -> m2: FStar.OrdMap.ordmap k v f -> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdMap.ordmap",
"Prims.l_Forall",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.OrdMap.select",
"Prims.prop"
] | [] | false | false | false | false | true | let equal (#k: eqtype) (#v: Type) (#f: cmp k) (m1 m2: ordmap k v f) =
| forall x. select #k #v #f x m1 == select #k #v #f x m2 | false |
FStar.OrdMap.fst | FStar.OrdMap.upd_order | val upd_order: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> y:v -> x':k -> y':v
-> m:ordmap k v f
-> Lemma (requires (x =!= x'))
(ensures (equal (update #k #v #f x y (update #k #v #f x' y' m))
(update #k #v #f x' y' (update #k #v #f x y m))))
[SMTPat (update #k #v #f x y (update #k #v #f x' y' m))] | val upd_order: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> y:v -> x':k -> y':v
-> m:ordmap k v f
-> Lemma (requires (x =!= x'))
(ensures (equal (update #k #v #f x y (update #k #v #f x' y' m))
(update #k #v #f x' y' (update #k #v #f x y m))))
[SMTPat (update #k #v #f x y (update #k #v #f x' y' m))] | let upd_order (#k:eqtype) (#v:Type) #f x y x' y' m =
let (Mk_map s1 g1) = update #k #v #f x' y' (update #k #v #f x y m) in
let (Mk_map s2 g2) = update #k #v #f x y (update #k #v #f x' y' m) in
cut (feq g1 g2) | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 17,
"end_line": 78,
"start_col": 0,
"start_line": 75
} | (*
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.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f
let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g
let const_on (#k:eqtype) (#v:Type) #f d x =
let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g
let select (#k:eqtype) (#v:Type) #f x m = (Mk_map?.m m) x
let insert (#a:eqtype) (#f:cmp a) (x:a) (s:ordset a f) = union #a #f (singleton #a #f x) s
let update (#k:eqtype) (#v:Type) #f x y m =
let s' = insert x (Mk_map?.d m) in
let g' = F.on_dom k (fun (x':k) -> if x' = x then Some y else (Mk_map?.m m) x') in
Mk_map s' g'
let contains (#k:eqtype) (#v:Type) #f x m = mem x (Mk_map?.d m)
let dom (#k:eqtype) (#v:Type) #f m = (Mk_map?.d m)
let remove (#k:eqtype) (#v:Type) #f x m =
let s' = remove x (Mk_map?.d m) in
let g' = F.on_dom k (fun x' -> if x' = x then None else (Mk_map?.m m) x') in
Mk_map s' g'
let choose (#k:eqtype) (#v:Type) #f m =
match OrdSet.choose (Mk_map?.d m) with
| None -> None
| Some x -> Some (x, Some?.v ((Mk_map?.m m) x))
let size (#k:eqtype) (#v:Type) #f m = OrdSet.size (Mk_map?.d m)
let equal (#k:eqtype) (#v:Type) (#f:cmp k) (m1:ordmap k v f) (m2:ordmap k v f) =
forall x. select #k #v #f x m1 == select #k #v #f x m2
let eq_intro (#k:eqtype) (#v:Type) #f m1 m2 = ()
let eq_lemma (#k:eqtype) (#v:Type) #f m1 m2 =
let Mk_map s1 g1 = m1 in
let Mk_map s2 g2 = m2 in
let _ = cut (feq g1 g2) in
let _ = OrdSet.eq_lemma s1 s2 in
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: k -> y: v -> x': k -> y': v -> m: FStar.OrdMap.ordmap k v f
-> FStar.Pervasives.Lemma (requires ~(x == x'))
(ensures
FStar.OrdMap.equal (FStar.OrdMap.update x y (FStar.OrdMap.update x' y' m))
(FStar.OrdMap.update x' y' (FStar.OrdMap.update x y m)))
[SMTPat (FStar.OrdMap.update x y (FStar.OrdMap.update x' y' m))] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdMap.ordmap",
"FStar.OrdSet.ordset",
"FStar.OrdMap.map_t",
"Prims.cut",
"FStar.FunctionalExtensionality.feq",
"FStar.Pervasives.Native.option",
"Prims.unit",
"FStar.OrdMap.update"
] | [] | false | false | true | false | false | let upd_order (#k: eqtype) (#v: Type) #f x y x' y' m =
| let Mk_map s1 g1 = update #k #v #f x' y' (update #k #v #f x y m) in
let Mk_map s2 g2 = update #k #v #f x y (update #k #v #f x' y' m) in
cut (feq g1 g2) | false |
FStar.OrdMap.fst | FStar.OrdMap.dom_empty_helper | val dom_empty_helper: #k:eqtype -> #v:Type -> #f:cmp k -> m:ordmap k v f
-> Lemma (requires (True))
(ensures ((dom #k #v #f m = OrdSet.empty) ==>
(m == empty #k #v #f))) | val dom_empty_helper: #k:eqtype -> #v:Type -> #f:cmp k -> m:ordmap k v f
-> Lemma (requires (True))
(ensures ((dom #k #v #f m = OrdSet.empty) ==>
(m == empty #k #v #f))) | let dom_empty_helper (#k:eqtype) (#v:Type) #f m =
let (Mk_map s g) = m in
if (not (s = OrdSet.empty)) then ()
else
let (Mk_map s' g') = empty #k #v #f in
cut (feq g g') | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 18,
"end_line": 119,
"start_col": 0,
"start_line": 114
} | (*
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.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f
let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g
let const_on (#k:eqtype) (#v:Type) #f d x =
let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g
let select (#k:eqtype) (#v:Type) #f x m = (Mk_map?.m m) x
let insert (#a:eqtype) (#f:cmp a) (x:a) (s:ordset a f) = union #a #f (singleton #a #f x) s
let update (#k:eqtype) (#v:Type) #f x y m =
let s' = insert x (Mk_map?.d m) in
let g' = F.on_dom k (fun (x':k) -> if x' = x then Some y else (Mk_map?.m m) x') in
Mk_map s' g'
let contains (#k:eqtype) (#v:Type) #f x m = mem x (Mk_map?.d m)
let dom (#k:eqtype) (#v:Type) #f m = (Mk_map?.d m)
let remove (#k:eqtype) (#v:Type) #f x m =
let s' = remove x (Mk_map?.d m) in
let g' = F.on_dom k (fun x' -> if x' = x then None else (Mk_map?.m m) x') in
Mk_map s' g'
let choose (#k:eqtype) (#v:Type) #f m =
match OrdSet.choose (Mk_map?.d m) with
| None -> None
| Some x -> Some (x, Some?.v ((Mk_map?.m m) x))
let size (#k:eqtype) (#v:Type) #f m = OrdSet.size (Mk_map?.d m)
let equal (#k:eqtype) (#v:Type) (#f:cmp k) (m1:ordmap k v f) (m2:ordmap k v f) =
forall x. select #k #v #f x m1 == select #k #v #f x m2
let eq_intro (#k:eqtype) (#v:Type) #f m1 m2 = ()
let eq_lemma (#k:eqtype) (#v:Type) #f m1 m2 =
let Mk_map s1 g1 = m1 in
let Mk_map s2 g2 = m2 in
let _ = cut (feq g1 g2) in
let _ = OrdSet.eq_lemma s1 s2 in
()
let upd_order (#k:eqtype) (#v:Type) #f x y x' y' m =
let (Mk_map s1 g1) = update #k #v #f x' y' (update #k #v #f x y m) in
let (Mk_map s2 g2) = update #k #v #f x y (update #k #v #f x' y' m) in
cut (feq g1 g2)
let upd_same_k (#k:eqtype) (#v:Type) #f x y y' m =
let (Mk_map s1 g1) = update #k #v #f x y m in
let (Mk_map s2 g2) = update #k #v #f x y (update #k #v #f x y' m) in
cut (feq g1 g2)
let sel_upd1 (#k:eqtype) (#v:Type) #f x y m = ()
let sel_upd2 (#k:eqtype) (#v:Type) #f x y x' m = ()
let sel_empty (#k:eqtype) (#v:Type) #f x = ()
let sel_contains (#k:eqtype) (#v:Type) #f x m = ()
let contains_upd1 (#k:eqtype) (#v:Type) #f x y x' m = ()
let contains_upd2 (#k:eqtype) (#v:Type) #f x y x' m = ()
let contains_empty (#k:eqtype) (#v:Type) #f x = ()
let contains_remove (#k:eqtype) (#v:Type) #f x y m = ()
let eq_remove (#k:eqtype) (#v:Type) #f x m =
let (Mk_map s g) = m in
let m' = remove #k #v #f x m in
let (Mk_map s' g') = m' in
let _ = cut (feq g g') in
()
let choose_empty (#k:eqtype) (#v:Type) #f = ()
private val dom_empty_helper: #k:eqtype -> #v:Type -> #f:cmp k -> m:ordmap k v f
-> Lemma (requires (True))
(ensures ((dom #k #v #f m = OrdSet.empty) ==> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m: FStar.OrdMap.ordmap k v f
-> FStar.Pervasives.Lemma
(ensures FStar.OrdMap.dom m = FStar.OrdSet.empty ==> m == FStar.OrdMap.empty) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdMap.ordmap",
"FStar.OrdSet.ordset",
"FStar.OrdMap.map_t",
"Prims.op_Negation",
"Prims.op_Equality",
"FStar.OrdSet.empty",
"Prims.bool",
"Prims.cut",
"FStar.FunctionalExtensionality.feq",
"FStar.Pervasives.Native.option",
"Prims.unit",
"FStar.OrdMap.empty"
] | [] | false | false | true | false | false | let dom_empty_helper (#k: eqtype) (#v: Type) #f m =
| let Mk_map s g = m in
if (not (s = OrdSet.empty))
then ()
else
let Mk_map s' g' = empty #k #v #f in
cut (feq g g') | false |
FStar.OrdMap.fst | FStar.OrdMap.eq_remove | val eq_remove: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> m:ordmap k v f
-> Lemma (requires (not (contains #k #v #f x m)))
(ensures (equal m (remove #k #v #f x m)))
[SMTPat (remove #k #v #f x m)] | val eq_remove: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> m:ordmap k v f
-> Lemma (requires (not (contains #k #v #f x m)))
(ensures (equal m (remove #k #v #f x m)))
[SMTPat (remove #k #v #f x m)] | let eq_remove (#k:eqtype) (#v:Type) #f x m =
let (Mk_map s g) = m in
let m' = remove #k #v #f x m in
let (Mk_map s' g') = m' in
let _ = cut (feq g g') in
() | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 4,
"end_line": 106,
"start_col": 0,
"start_line": 101
} | (*
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.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f
let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g
let const_on (#k:eqtype) (#v:Type) #f d x =
let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g
let select (#k:eqtype) (#v:Type) #f x m = (Mk_map?.m m) x
let insert (#a:eqtype) (#f:cmp a) (x:a) (s:ordset a f) = union #a #f (singleton #a #f x) s
let update (#k:eqtype) (#v:Type) #f x y m =
let s' = insert x (Mk_map?.d m) in
let g' = F.on_dom k (fun (x':k) -> if x' = x then Some y else (Mk_map?.m m) x') in
Mk_map s' g'
let contains (#k:eqtype) (#v:Type) #f x m = mem x (Mk_map?.d m)
let dom (#k:eqtype) (#v:Type) #f m = (Mk_map?.d m)
let remove (#k:eqtype) (#v:Type) #f x m =
let s' = remove x (Mk_map?.d m) in
let g' = F.on_dom k (fun x' -> if x' = x then None else (Mk_map?.m m) x') in
Mk_map s' g'
let choose (#k:eqtype) (#v:Type) #f m =
match OrdSet.choose (Mk_map?.d m) with
| None -> None
| Some x -> Some (x, Some?.v ((Mk_map?.m m) x))
let size (#k:eqtype) (#v:Type) #f m = OrdSet.size (Mk_map?.d m)
let equal (#k:eqtype) (#v:Type) (#f:cmp k) (m1:ordmap k v f) (m2:ordmap k v f) =
forall x. select #k #v #f x m1 == select #k #v #f x m2
let eq_intro (#k:eqtype) (#v:Type) #f m1 m2 = ()
let eq_lemma (#k:eqtype) (#v:Type) #f m1 m2 =
let Mk_map s1 g1 = m1 in
let Mk_map s2 g2 = m2 in
let _ = cut (feq g1 g2) in
let _ = OrdSet.eq_lemma s1 s2 in
()
let upd_order (#k:eqtype) (#v:Type) #f x y x' y' m =
let (Mk_map s1 g1) = update #k #v #f x' y' (update #k #v #f x y m) in
let (Mk_map s2 g2) = update #k #v #f x y (update #k #v #f x' y' m) in
cut (feq g1 g2)
let upd_same_k (#k:eqtype) (#v:Type) #f x y y' m =
let (Mk_map s1 g1) = update #k #v #f x y m in
let (Mk_map s2 g2) = update #k #v #f x y (update #k #v #f x y' m) in
cut (feq g1 g2)
let sel_upd1 (#k:eqtype) (#v:Type) #f x y m = ()
let sel_upd2 (#k:eqtype) (#v:Type) #f x y x' m = ()
let sel_empty (#k:eqtype) (#v:Type) #f x = ()
let sel_contains (#k:eqtype) (#v:Type) #f x m = ()
let contains_upd1 (#k:eqtype) (#v:Type) #f x y x' m = ()
let contains_upd2 (#k:eqtype) (#v:Type) #f x y x' m = ()
let contains_empty (#k:eqtype) (#v:Type) #f x = ()
let contains_remove (#k:eqtype) (#v:Type) #f x y m = () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: k -> m: FStar.OrdMap.ordmap k v f
-> FStar.Pervasives.Lemma (requires Prims.op_Negation (FStar.OrdMap.contains x m))
(ensures FStar.OrdMap.equal m (FStar.OrdMap.remove x m))
[SMTPat (FStar.OrdMap.remove x m)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdMap.ordmap",
"FStar.OrdSet.ordset",
"FStar.OrdMap.map_t",
"Prims.unit",
"Prims.cut",
"FStar.FunctionalExtensionality.feq",
"FStar.Pervasives.Native.option",
"FStar.OrdMap.remove"
] | [] | false | false | true | false | false | let eq_remove (#k: eqtype) (#v: Type) #f x m =
| let Mk_map s g = m in
let m' = remove #k #v #f x m in
let Mk_map s' g' = m' in
let _ = cut (feq g g') in
() | false |
FStar.OrdMap.fst | FStar.OrdMap.upd_same_k | val upd_same_k: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> y:v -> y':v
-> m:ordmap k v f
-> Lemma (requires (True))
(ensures (equal (update #k #v #f x y (update #k #v #f x y' m))
(update #k #v #f x y m)))
[SMTPat (update #k #v #f x y (update #k #v #f x y' m))] | val upd_same_k: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> y:v -> y':v
-> m:ordmap k v f
-> Lemma (requires (True))
(ensures (equal (update #k #v #f x y (update #k #v #f x y' m))
(update #k #v #f x y m)))
[SMTPat (update #k #v #f x y (update #k #v #f x y' m))] | let upd_same_k (#k:eqtype) (#v:Type) #f x y y' m =
let (Mk_map s1 g1) = update #k #v #f x y m in
let (Mk_map s2 g2) = update #k #v #f x y (update #k #v #f x y' m) in
cut (feq g1 g2) | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 17,
"end_line": 83,
"start_col": 0,
"start_line": 80
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f
let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g
let const_on (#k:eqtype) (#v:Type) #f d x =
let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g
let select (#k:eqtype) (#v:Type) #f x m = (Mk_map?.m m) x
let insert (#a:eqtype) (#f:cmp a) (x:a) (s:ordset a f) = union #a #f (singleton #a #f x) s
let update (#k:eqtype) (#v:Type) #f x y m =
let s' = insert x (Mk_map?.d m) in
let g' = F.on_dom k (fun (x':k) -> if x' = x then Some y else (Mk_map?.m m) x') in
Mk_map s' g'
let contains (#k:eqtype) (#v:Type) #f x m = mem x (Mk_map?.d m)
let dom (#k:eqtype) (#v:Type) #f m = (Mk_map?.d m)
let remove (#k:eqtype) (#v:Type) #f x m =
let s' = remove x (Mk_map?.d m) in
let g' = F.on_dom k (fun x' -> if x' = x then None else (Mk_map?.m m) x') in
Mk_map s' g'
let choose (#k:eqtype) (#v:Type) #f m =
match OrdSet.choose (Mk_map?.d m) with
| None -> None
| Some x -> Some (x, Some?.v ((Mk_map?.m m) x))
let size (#k:eqtype) (#v:Type) #f m = OrdSet.size (Mk_map?.d m)
let equal (#k:eqtype) (#v:Type) (#f:cmp k) (m1:ordmap k v f) (m2:ordmap k v f) =
forall x. select #k #v #f x m1 == select #k #v #f x m2
let eq_intro (#k:eqtype) (#v:Type) #f m1 m2 = ()
let eq_lemma (#k:eqtype) (#v:Type) #f m1 m2 =
let Mk_map s1 g1 = m1 in
let Mk_map s2 g2 = m2 in
let _ = cut (feq g1 g2) in
let _ = OrdSet.eq_lemma s1 s2 in
()
let upd_order (#k:eqtype) (#v:Type) #f x y x' y' m =
let (Mk_map s1 g1) = update #k #v #f x' y' (update #k #v #f x y m) in
let (Mk_map s2 g2) = update #k #v #f x y (update #k #v #f x' y' m) in
cut (feq g1 g2) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: k -> y: v -> y': v -> m: FStar.OrdMap.ordmap k v f
-> FStar.Pervasives.Lemma
(ensures
FStar.OrdMap.equal (FStar.OrdMap.update x y (FStar.OrdMap.update x y' m))
(FStar.OrdMap.update x y m))
[SMTPat (FStar.OrdMap.update x y (FStar.OrdMap.update x y' m))] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdMap.ordmap",
"FStar.OrdSet.ordset",
"FStar.OrdMap.map_t",
"Prims.cut",
"FStar.FunctionalExtensionality.feq",
"FStar.Pervasives.Native.option",
"Prims.unit",
"FStar.OrdMap.update"
] | [] | false | false | true | false | false | let upd_same_k (#k: eqtype) (#v: Type) #f x y y' m =
| let Mk_map s1 g1 = update #k #v #f x y m in
let Mk_map s2 g2 = update #k #v #f x y (update #k #v #f x y' m) in
cut (feq g1 g2) | false |
FStar.OrdMap.fst | FStar.OrdMap.choose_m | val choose_m: #k:eqtype -> #v:Type -> #f:cmp k -> m:ordmap k v f
-> Lemma (requires (~ (equal m (empty #k #v #f))))
(ensures (Some? (choose #k #v #f m) /\
(select #k #v #f (fst (Some?.v (choose #k #v #f m))) m ==
Some (snd (Some?.v (choose #k #v #f m)))) /\
(equal m (update #k #v #f (fst (Some?.v (choose #k #v #f m)))
(snd (Some?.v (choose #k #v #f m)))
(remove #k #v #f (fst (Some?.v (choose #k #v #f m))) m)))))
[SMTPat (choose #k #v #f m)] | val choose_m: #k:eqtype -> #v:Type -> #f:cmp k -> m:ordmap k v f
-> Lemma (requires (~ (equal m (empty #k #v #f))))
(ensures (Some? (choose #k #v #f m) /\
(select #k #v #f (fst (Some?.v (choose #k #v #f m))) m ==
Some (snd (Some?.v (choose #k #v #f m)))) /\
(equal m (update #k #v #f (fst (Some?.v (choose #k #v #f m)))
(snd (Some?.v (choose #k #v #f m)))
(remove #k #v #f (fst (Some?.v (choose #k #v #f m))) m)))))
[SMTPat (choose #k #v #f m)] | let choose_m (#k:eqtype) (#v:Type) #f m =
dom_empty_helper #k #v #f m;
let c = choose #k #v #f m in
match c with
| None -> ()
| Some (x, y) ->
let m' = remove #k #v #f x m in
let (Mk_map s' g') = m' in
let (Mk_map s'' g'') = update #k #v #f x y m' in
cut (feq (Mk_map?.m m) g'') | {
"file_name": "ulib/experimental/FStar.OrdMap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 33,
"end_line": 130,
"start_col": 0,
"start_line": 121
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.OrdMap
open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality
let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}
noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
| Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f
let empty (#k:eqtype) (#v:Type) #f =
let d = OrdSet.empty in
let g = F.on_dom k (fun x -> None) in
Mk_map d g
let const_on (#k:eqtype) (#v:Type) #f d x =
let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
Mk_map d g
let select (#k:eqtype) (#v:Type) #f x m = (Mk_map?.m m) x
let insert (#a:eqtype) (#f:cmp a) (x:a) (s:ordset a f) = union #a #f (singleton #a #f x) s
let update (#k:eqtype) (#v:Type) #f x y m =
let s' = insert x (Mk_map?.d m) in
let g' = F.on_dom k (fun (x':k) -> if x' = x then Some y else (Mk_map?.m m) x') in
Mk_map s' g'
let contains (#k:eqtype) (#v:Type) #f x m = mem x (Mk_map?.d m)
let dom (#k:eqtype) (#v:Type) #f m = (Mk_map?.d m)
let remove (#k:eqtype) (#v:Type) #f x m =
let s' = remove x (Mk_map?.d m) in
let g' = F.on_dom k (fun x' -> if x' = x then None else (Mk_map?.m m) x') in
Mk_map s' g'
let choose (#k:eqtype) (#v:Type) #f m =
match OrdSet.choose (Mk_map?.d m) with
| None -> None
| Some x -> Some (x, Some?.v ((Mk_map?.m m) x))
let size (#k:eqtype) (#v:Type) #f m = OrdSet.size (Mk_map?.d m)
let equal (#k:eqtype) (#v:Type) (#f:cmp k) (m1:ordmap k v f) (m2:ordmap k v f) =
forall x. select #k #v #f x m1 == select #k #v #f x m2
let eq_intro (#k:eqtype) (#v:Type) #f m1 m2 = ()
let eq_lemma (#k:eqtype) (#v:Type) #f m1 m2 =
let Mk_map s1 g1 = m1 in
let Mk_map s2 g2 = m2 in
let _ = cut (feq g1 g2) in
let _ = OrdSet.eq_lemma s1 s2 in
()
let upd_order (#k:eqtype) (#v:Type) #f x y x' y' m =
let (Mk_map s1 g1) = update #k #v #f x' y' (update #k #v #f x y m) in
let (Mk_map s2 g2) = update #k #v #f x y (update #k #v #f x' y' m) in
cut (feq g1 g2)
let upd_same_k (#k:eqtype) (#v:Type) #f x y y' m =
let (Mk_map s1 g1) = update #k #v #f x y m in
let (Mk_map s2 g2) = update #k #v #f x y (update #k #v #f x y' m) in
cut (feq g1 g2)
let sel_upd1 (#k:eqtype) (#v:Type) #f x y m = ()
let sel_upd2 (#k:eqtype) (#v:Type) #f x y x' m = ()
let sel_empty (#k:eqtype) (#v:Type) #f x = ()
let sel_contains (#k:eqtype) (#v:Type) #f x m = ()
let contains_upd1 (#k:eqtype) (#v:Type) #f x y x' m = ()
let contains_upd2 (#k:eqtype) (#v:Type) #f x y x' m = ()
let contains_empty (#k:eqtype) (#v:Type) #f x = ()
let contains_remove (#k:eqtype) (#v:Type) #f x y m = ()
let eq_remove (#k:eqtype) (#v:Type) #f x m =
let (Mk_map s g) = m in
let m' = remove #k #v #f x m in
let (Mk_map s' g') = m' in
let _ = cut (feq g g') in
()
let choose_empty (#k:eqtype) (#v:Type) #f = ()
private val dom_empty_helper: #k:eqtype -> #v:Type -> #f:cmp k -> m:ordmap k v f
-> Lemma (requires (True))
(ensures ((dom #k #v #f m = OrdSet.empty) ==>
(m == empty #k #v #f)))
let dom_empty_helper (#k:eqtype) (#v:Type) #f m =
let (Mk_map s g) = m in
if (not (s = OrdSet.empty)) then ()
else
let (Mk_map s' g') = empty #k #v #f in
cut (feq g g') | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.OrdMap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m: FStar.OrdMap.ordmap k v f
-> FStar.Pervasives.Lemma (requires ~(FStar.OrdMap.equal m FStar.OrdMap.empty))
(ensures
Some? (FStar.OrdMap.choose m) /\
FStar.OrdMap.select (FStar.Pervasives.Native.fst (Some?.v (FStar.OrdMap.choose m))) m ==
FStar.Pervasives.Native.Some (FStar.Pervasives.Native.snd (Some?.v (FStar.OrdMap.choose m))) /\
FStar.OrdMap.equal m
(FStar.OrdMap.update (FStar.Pervasives.Native.fst (Some?.v (FStar.OrdMap.choose m)))
(FStar.Pervasives.Native.snd (Some?.v (FStar.OrdMap.choose m)))
(FStar.OrdMap.remove (FStar.Pervasives.Native.fst (Some?.v (FStar.OrdMap.choose m))) m
)))
[SMTPat (FStar.OrdMap.choose m)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"FStar.OrdSet.cmp",
"FStar.OrdMap.ordmap",
"FStar.OrdSet.ordset",
"FStar.OrdMap.map_t",
"Prims.cut",
"FStar.FunctionalExtensionality.feq",
"FStar.Pervasives.Native.option",
"FStar.OrdMap.__proj__Mk_map__item__m",
"Prims.unit",
"FStar.OrdMap.update",
"FStar.OrdMap.remove",
"FStar.Pervasives.Native.tuple2",
"FStar.OrdMap.choose",
"FStar.OrdMap.dom_empty_helper"
] | [] | false | false | true | false | false | let choose_m (#k: eqtype) (#v: Type) #f m =
| dom_empty_helper #k #v #f m;
let c = choose #k #v #f m in
match c with
| None -> ()
| Some (x, y) ->
let m' = remove #k #v #f x m in
let Mk_map s' g' = m' in
let Mk_map s'' g'' = update #k #v #f x y m' in
cut (feq (Mk_map?.m m) g'') | false |
CQueue.fst | CQueue.queue_is_empty | val queue_is_empty
(#a: Type)
(x: t a)
(l: Ghost.erased (v a))
: Steel bool
(queue x l)
(fun _ -> queue x l)
(requires (fun _ -> True))
(ensures (fun _ res _ ->
res == Nil? (datas l)
)) | val queue_is_empty
(#a: Type)
(x: t a)
(l: Ghost.erased (v a))
: Steel bool
(queue x l)
(fun _ -> queue x l)
(requires (fun _ -> True))
(ensures (fun _ res _ ->
res == Nil? (datas l)
)) | let queue_is_empty #a x l =
let head0 = elim_queue_head x l in
let head = read (cllist_head x) in
let res = ccell_ptrvalue_is_null head in
llist_fragment_head_is_nil l (cllist_head x) head0;
intro_queue_head x l head0;
return res | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 12,
"end_line": 1331,
"start_col": 0,
"start_line": 1325
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead
unfold
let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a))
val intro_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_tail l phead)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil
l phead
=
intro_vconst phead;
change_equal_slprop
(vconst phead)
(llist_fragment_tail l phead)
val elim_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l phead)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil
l phead
=
change_equal_slprop
(llist_fragment_tail l phead)
(vconst phead);
elim_vconst phead
val intro_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: Ghost.erased (ref (ccell_ptrvalue a)))
(tail: Ghost.erased (ccell_lvalue a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail))
(fun res -> llist_fragment_tail res phead)
(fun h ->
sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\
sel ptail h == Ghost.reveal tail
)
(fun h res h' ->
Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\
sel_llist_fragment_tail res phead h' == ccell_next tail
)
#push-options "--z3rlimit 16"
let intro_llist_fragment_tail_snoc
#_ #a l phead ptail tail
=
let d = gget (vptr (ccell_data tail)) in
let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in
intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l');
intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a);
intro_vdep
(vptr ptail `vrefine` ccell_is_lvalue_refine a)
(vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l')
(llist_fragment_tail_cons_lvalue_payload l');
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead);
intro_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)
(vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l')
(llist_fragment_tail_cons_next_payload l');
intro_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l')
(llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead));
llist_fragment_tail_eq_cons l' phead;
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead))
(llist_fragment_tail l' phead);
let g' = gget (llist_fragment_tail l' phead) in
assert (Ghost.reveal g' == ccell_next tail);
noop ();
l'
#pop-options
[@@erasable]
noeq
type ll_unsnoc_t (a: Type) = {
ll_unsnoc_l: list a;
ll_unsnoc_ptail: ref (ccell_ptrvalue a);
ll_unsnoc_tail: ccell_lvalue a;
}
val elim_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost (ll_unsnoc_t a) opened
(llist_fragment_tail l phead)
(fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail))
(fun _ -> Cons? l)
(fun h res h' ->
Cons? l /\
Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\
sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\
sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\
sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\
sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail)
)
#push-options "--z3rlimit 32"
#restart-solver
let elim_llist_fragment_tail_snoc
#_ #a l phead
=
let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in
llist_fragment_tail_eq_cons l0 phead;
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
elim_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0)
(llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
let ptail = elim_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail_cons_next_payload l0)
in
let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in
change_equal_slprop
(llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail))
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0);
let tail = elim_vdep
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a)
(llist_fragment_tail_cons_lvalue_payload l0)
in
elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a);
let res = {
ll_unsnoc_l = unsnoc_hd l0;
ll_unsnoc_ptail = Ghost.reveal ptail0;
ll_unsnoc_tail = Ghost.reveal tail;
} in
change_equal_slprop
(vptr (Ghost.reveal ptail0))
(vptr res.ll_unsnoc_ptail);
change_equal_slprop
(llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail))
(vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0);
elim_vrefine
(vptr (ccell_data res.ll_unsnoc_tail))
(llist_fragment_tail_cons_data_refine l0);
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail res.ll_unsnoc_l phead);
res
#pop-options
let rec llist_fragment_tail_append
(#opened: _)
(#a: Type)
(phead0: ref (ccell_ptrvalue a))
(l1: Ghost.erased (list a))
(phead1: Ghost.erased (ref (ccell_ptrvalue a)))
(l2: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1)
(fun res -> llist_fragment_tail res phead0)
(fun h ->
Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h
)
(fun h res h' ->
Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
(sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h
)
(decreases (L.length (Ghost.reveal l2)))
=
let g1 = gget (llist_fragment_tail l1 phead0) in
assert (Ghost.reveal phead1 == Ghost.reveal g1);
if Nil? l2
then begin
L.append_l_nil (Ghost.reveal l1);
elim_llist_fragment_tail_nil l2 phead1;
l1
end else begin
let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in
let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in
L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d];
let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in
intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
end
let queue_tail_refine
(#a: Type)
(tail1: ref (ccell_ptrvalue a))
(tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop
= ccell_ptrvalue_is_null tl == true /\ tail1 == tail2
[@@__steel_reduce__]
let queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop
= vptr tail2 `vrefine` queue_tail_refine tail1 tail2
[@@__steel_reduce__]
let queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop
= vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1
[@@__steel_reduce__; __reduce__]
let queue_tail
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
=
llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l
val intro_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun _ -> queue_tail x l)
(fun h ->
sel_llist_fragment_tail l (cllist_head x) h == tail /\
sel (cllist_tail x) h == tail /\
ccell_ptrvalue_is_null (sel tail h)
)
(fun _ _ _ -> True)
let intro_queue_tail
x l tail
=
intro_vrefine (vptr tail) (queue_tail_refine tail tail);
intro_vdep2
(vptr (cllist_tail x))
(vptr tail `vrefine` queue_tail_refine tail tail)
tail
(queue_tail_dep2 x l tail);
intro_vdep2
(llist_fragment_tail l (cllist_head x))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail)
tail
(queue_tail_dep1 x l)
val elim_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(queue_tail x l)
(fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun h -> True)
(fun _ tail h ->
sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\
sel (cllist_tail x) h == Ghost.reveal tail /\
ccell_ptrvalue_is_null (h (vptr tail))
)
let elim_queue_tail
#_ #a x l
=
let tail0 = elim_vdep
(llist_fragment_tail l (cllist_head x))
(queue_tail_dep1 x l)
in
let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in
change_equal_slprop
(queue_tail_dep1 x l (Ghost.reveal tail0))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0);
let tail2 = elim_vdep
(vptr (cllist_tail x))
(queue_tail_dep2 x l tail0)
in
let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in
change_equal_slprop
(queue_tail_dep2 x l tail0 (Ghost.reveal tail2))
(vptr tail3 `vrefine` queue_tail_refine tail0 tail3);
elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3);
change_equal_slprop
(vptr tail3)
(vptr tail);
tail
(* view from the head *)
let llist_fragment_head_data_refine
(#a: Type)
(d: a)
(c: vcell a)
: Tot prop
= c.vcell_data == d
let llist_fragment_head_payload
(#a: Type)
(head: ccell_ptrvalue a)
(d: a)
(llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop))
(x: t_of (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine d)))
: Tot vprop
=
llist_fragment_head (ccell_next (fst x)) (snd x).vcell_next
let rec llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Tot vprop
(decreases (Ghost.reveal l))
=
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
let t_of_llist_fragment_head
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(t_of (llist_fragment_head l phead head) == ref (ccell_ptrvalue a) & ccell_ptrvalue a)
= ()
unfold
let sel_llist_fragment_head
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_head l phead head) /\ True) })
: GTot (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
=
coerce (h (llist_fragment_head l phead head)) (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
val intro_llist_fragment_head_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_head l phead head)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_head l phead head h' == (phead, head))
let intro_llist_fragment_head_nil
l phead head
=
intro_vconst (phead, head);
change_equal_slprop
(vconst (phead, head))
(llist_fragment_head l phead head)
val elim_llist_fragment_head_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_head l phead head h == (phead, head))
let elim_llist_fragment_head_nil
l phead head
=
change_equal_slprop
(llist_fragment_head l phead head)
(vconst (phead, head));
elim_vconst (phead, head)
let llist_fragment_head_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(requires (Cons? (Ghost.reveal l)))
(ensures (
llist_fragment_head l phead head ==
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
))
= assert_norm
(llist_fragment_head l phead head == (
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
))
val intro_llist_fragment_head_cons
(#opened: _)
(#a: Type) (phead: ref (ccell_ptrvalue a)) (head: ccell_lvalue a) (next: (ccell_ptrvalue a)) (tl: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(ccell head `star` llist_fragment_head tl (ccell_next head) next)
(fun res -> llist_fragment_head res phead head)
(fun h -> (h (ccell head)).vcell_next == next)
(fun h res h' ->
Ghost.reveal res == (h (ccell head)).vcell_data :: Ghost.reveal tl /\
h' (llist_fragment_head res phead head) == h (llist_fragment_head tl (ccell_next head) next)
)
let intro_llist_fragment_head_cons
#_ #a phead head next tl
=
let vc = gget (ccell head) in
let l' : (l' : Ghost.erased (list a) { Cons? l' }) = Ghost.hide (vc.vcell_data :: tl) in
intro_ccell_is_lvalue head;
intro_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l'));
intro_vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l')))
(llist_fragment_head tl (ccell_next head) next)
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l')));
llist_fragment_head_eq_cons l' phead head;
change_equal_slprop
(vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l')))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l'))))
(llist_fragment_head l' phead head);
l'
[@@erasable]
noeq
type ll_uncons_t
(a: Type)
= {
ll_uncons_pnext: Ghost.erased (ref (ccell_ptrvalue a));
ll_uncons_next: Ghost.erased (ccell_ptrvalue a);
ll_uncons_tl: Ghost.erased (list a);
}
val elim_llist_fragment_head_cons
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost (ll_uncons_t a) opened
(llist_fragment_head l phead head)
(fun res -> ccell head `star` llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next)
(fun _ -> Cons? (Ghost.reveal l))
(fun h res h' ->
ccell_ptrvalue_is_null head == false /\
Ghost.reveal l == (h' (ccell head)).vcell_data :: Ghost.reveal res.ll_uncons_tl /\
Ghost.reveal res.ll_uncons_pnext == ccell_next head /\
Ghost.reveal res.ll_uncons_next == (h' (ccell head)).vcell_next /\
h' (llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next) == h (llist_fragment_head l phead head)
)
let elim_llist_fragment_head_cons
#_ #a l0 phead head
=
let l : (l : Ghost.erased (list a) { Cons? l }) = l0 in
change_equal_slprop
(llist_fragment_head l0 phead head)
(llist_fragment_head l phead head);
llist_fragment_head_eq_cons l phead head;
change_equal_slprop
(llist_fragment_head l phead head)
(vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l)))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l))));
let x = elim_vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l)))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)))
in
let head2 = gget (ccell_is_lvalue head) in
elim_ccell_is_lvalue head;
elim_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l));
let vhead2 = gget (ccell head) in
let res = {
ll_uncons_pnext = ccell_next head2;
ll_uncons_next = vhead2.vcell_next;
ll_uncons_tl = L.tl l;
} in
change_equal_slprop
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)) (Ghost.reveal x))
(llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next);
res
let rec llist_fragment_head_append
(#opened: _)
(#a: Type)
(l1: Ghost.erased (list a))
(phead1: ref (ccell_ptrvalue a))
(head1: ccell_ptrvalue a)
(l2: Ghost.erased (list a))
(phead2: ref (ccell_ptrvalue a))
(head2: ccell_ptrvalue a)
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_head l1 phead1 head1 `star` llist_fragment_head l2 phead2 head2)
(fun l -> llist_fragment_head l phead1 head1)
(fun h -> sel_llist_fragment_head l1 phead1 head1 h == (Ghost.reveal phead2, Ghost.reveal head2))
(fun h l h' ->
Ghost.reveal l == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
h' (llist_fragment_head l phead1 head1) == h (llist_fragment_head l2 phead2 head2)
)
(decreases (Ghost.reveal l1))
=
if Nil? l1
then begin
elim_llist_fragment_head_nil l1 phead1 head1;
change_equal_slprop
(llist_fragment_head l2 phead2 head2)
(llist_fragment_head l2 phead1 head1);
l2
end else begin
let u = elim_llist_fragment_head_cons l1 phead1 head1 in
let head1' : Ghost.erased (ccell_lvalue a) = head1 in
let l3 = llist_fragment_head_append u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next l2 phead2 head2 in
change_equal_slprop
(llist_fragment_head l3 u.ll_uncons_pnext u.ll_uncons_next)
(llist_fragment_head l3 (ccell_next head1') u.ll_uncons_next);
change_equal_slprop
(ccell head1)
(ccell head1');
let l4 = intro_llist_fragment_head_cons phead1 head1' u.ll_uncons_next l3 in
change_equal_slprop
(llist_fragment_head l4 phead1 head1')
(llist_fragment_head l4 phead1 head1);
l4
end
let rec llist_fragment_head_to_tail
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(vptr phead `star` llist_fragment_head l phead head)
(fun res -> llist_fragment_tail l phead `star` vptr res)
(fun h -> h (vptr phead) == head)
(fun h res h' ->
let v = sel_llist_fragment_head l phead head h in
fst v == Ghost.reveal res /\
fst v == sel_llist_fragment_tail l phead h' /\
snd v == h' (vptr res)
)
(decreases (L.length (Ghost.reveal l)))
=
if Nil? l
then begin
let ptail = Ghost.hide phead in
let gh = gget (vptr phead) in
assert (Ghost.reveal gh == head);
elim_llist_fragment_head_nil l phead head;
intro_llist_fragment_tail_nil l phead;
change_equal_slprop
(vptr phead)
(vptr ptail);
ptail
end else begin
intro_llist_fragment_tail_nil [] phead;
change_equal_slprop
(vptr phead)
(vptr (Ghost.reveal (Ghost.hide phead)));
let uc = elim_llist_fragment_head_cons l phead head in
let head' = elim_ccell_ghost head in
change_equal_slprop
(vptr (ccell_next head'))
(vptr uc.ll_uncons_pnext);
let lc = intro_llist_fragment_tail_snoc [] phead phead head' in
let ptail = llist_fragment_head_to_tail
uc.ll_uncons_tl
uc.ll_uncons_pnext
uc.ll_uncons_next
in
let l' = llist_fragment_tail_append phead lc uc.ll_uncons_pnext uc.ll_uncons_tl in
change_equal_slprop
(llist_fragment_tail l' phead)
(llist_fragment_tail l phead);
ptail
end
#push-options "--z3rlimit 16"
#restart-solver
let rec llist_fragment_tail_to_head
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: ref (ccell_ptrvalue a))
: SteelGhost (Ghost.erased (ccell_ptrvalue a)) opened
(llist_fragment_tail l phead `star` vptr ptail)
(fun head -> vptr phead `star` llist_fragment_head l phead (Ghost.reveal head))
(fun h -> Ghost.reveal ptail == sel_llist_fragment_tail l phead h)
(fun h head h' ->
let v = sel_llist_fragment_head l phead head h' in
fst v == ptail /\
snd v == h (vptr ptail) /\
h' (vptr phead) == Ghost.reveal head
)
(decreases (L.length (Ghost.reveal l)))
=
if Nil? l
then begin
let g = gget (llist_fragment_tail l phead) in
assert (Ghost.reveal g == ptail);
elim_llist_fragment_tail_nil l phead;
change_equal_slprop
(vptr ptail)
(vptr phead);
let head = gget (vptr phead) in
intro_llist_fragment_head_nil l phead head;
head
end else begin
let us = elim_llist_fragment_tail_snoc l phead in
let tail = gget (vptr ptail) in
assert (ccell_next us.ll_unsnoc_tail == ptail);
intro_llist_fragment_head_nil [] (ccell_next us.ll_unsnoc_tail) tail;
change_equal_slprop
(vptr ptail)
(vptr (ccell_next us.ll_unsnoc_tail));
intro_ccell us.ll_unsnoc_tail;
let lc = intro_llist_fragment_head_cons us.ll_unsnoc_ptail us.ll_unsnoc_tail tail [] in
let head = llist_fragment_tail_to_head us.ll_unsnoc_l phead us.ll_unsnoc_ptail in
let g = gget (llist_fragment_head us.ll_unsnoc_l phead head) in
let g : Ghost.erased (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = Ghost.hide (Ghost.reveal g) in
assert (Ghost.reveal g == (Ghost.reveal us.ll_unsnoc_ptail, Ghost.reveal us.ll_unsnoc_tail));
let l' = llist_fragment_head_append us.ll_unsnoc_l phead head lc us.ll_unsnoc_ptail us.ll_unsnoc_tail in
change_equal_slprop
(llist_fragment_head l' phead head)
(llist_fragment_head l phead head);
head
end
#pop-options
val llist_fragment_head_is_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> llist_fragment_head l phead head)
(fun h -> ccell_ptrvalue_is_null (snd (sel_llist_fragment_head l phead head h)) == true)
(fun h _ h' ->
Nil? l == ccell_ptrvalue_is_null head /\
h' (llist_fragment_head l phead head) == h (llist_fragment_head l phead head)
)
let llist_fragment_head_is_nil
l phead head
=
if Nil? l
then begin
elim_llist_fragment_head_nil l phead head;
assert (ccell_ptrvalue_is_null head == true);
intro_llist_fragment_head_nil l phead head
end else begin
let r = elim_llist_fragment_head_cons l phead head in
let head2 : ccell_lvalue _ = head in
change_equal_slprop
(llist_fragment_head r.ll_uncons_tl r.ll_uncons_pnext r.ll_uncons_next)
(llist_fragment_head r.ll_uncons_tl (ccell_next head2) r.ll_uncons_next);
change_equal_slprop
(ccell head)
(ccell head2);
let l' = intro_llist_fragment_head_cons phead head2 r.ll_uncons_next r.ll_uncons_tl in
change_equal_slprop
(llist_fragment_head l' phead head2)
(llist_fragment_head l phead head)
end
val llist_fragment_head_cons_change_phead
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
(phead' : ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> llist_fragment_head l phead' head)
(fun _ -> Cons? l)
(fun h _ h' -> h' (llist_fragment_head l phead' head) == h (llist_fragment_head l phead head))
let llist_fragment_head_cons_change_phead
l phead head phead'
=
let u = elim_llist_fragment_head_cons l phead head in
let head2 : ccell_lvalue _ = head in
change_equal_slprop
(ccell head)
(ccell head2);
change_equal_slprop
(llist_fragment_head u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next)
(llist_fragment_head u.ll_uncons_tl (ccell_next head2) u.ll_uncons_next);
let l' = intro_llist_fragment_head_cons phead' head2 u.ll_uncons_next u.ll_uncons_tl in
change_equal_slprop
(llist_fragment_head l' phead' head2)
(llist_fragment_head l phead' head)
let queue_head_refine
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
(tl: ref (ccell_ptrvalue a))
: Tot prop
= let ptl : (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = ptl in
tl == fst ptl /\ ccell_ptrvalue_is_null (snd ptl) == true
let queue_head_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
: Tot vprop
= vptr (cllist_tail x) `vrefine` queue_head_refine x l hd ptl
let queue_head_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
: Tot vprop
= llist_fragment_head l (cllist_head x) hd `vdep` queue_head_dep1 x l hd
[@@__reduce__]
let queue_head
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
= vptr (cllist_head x) `vdep` queue_head_dep2 x l
val intro_queue_head
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: Ghost.erased (ccell_ptrvalue a))
: SteelGhost unit opened
(vptr (cllist_head x) `star` llist_fragment_head l (cllist_head x) hd `star` vptr (cllist_tail x))
(fun _ -> queue_head x l)
(fun h -> (
let frag = (sel_llist_fragment_head l (cllist_head x) hd) h in
sel (cllist_head x) h == Ghost.reveal hd /\
sel (cllist_tail x) h == fst frag /\
ccell_ptrvalue_is_null (snd frag) == true
))
(fun _ _ _ -> True)
let intro_queue_head
#_ #a x l hd
=
let ptl = gget (llist_fragment_head l (cllist_head x) hd) in
intro_vrefine
(vptr (cllist_tail x))
(queue_head_refine x l hd ptl);
assert_norm (vptr (cllist_tail x) `vrefine` queue_head_refine x l hd ptl == queue_head_dep1 x l hd ptl);
intro_vdep
(llist_fragment_head l (cllist_head x) hd)
(vptr (cllist_tail x) `vrefine` queue_head_refine x l hd ptl)
(queue_head_dep1 x l hd);
intro_vdep
(vptr (cllist_head x))
(llist_fragment_head l (cllist_head x) hd `vdep` queue_head_dep1 x l hd)
(queue_head_dep2 x l)
val elim_queue_head
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhost (Ghost.erased (ccell_ptrvalue a)) opened
(queue_head x l)
(fun hd -> vptr (cllist_head x) `star` llist_fragment_head l (cllist_head x) hd `star` vptr (cllist_tail x))
(fun _ -> True)
(fun _ hd h -> (
let frag = (sel_llist_fragment_head l (cllist_head x) hd) h in
sel (cllist_head x) h == Ghost.reveal hd /\
sel (cllist_tail x) h == fst frag /\
ccell_ptrvalue_is_null (snd frag) == true
))
let elim_queue_head
#_ #a x l
=
let hd = elim_vdep
(vptr (cllist_head x))
(queue_head_dep2 x l)
in
let ptl = elim_vdep
(llist_fragment_head l (cllist_head x) hd)
(queue_head_dep1 x l hd)
in
elim_vrefine
(vptr (cllist_tail x))
(queue_head_refine x l hd ptl);
hd
let queue_head_to_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhostT unit opened
(queue_head x l)
(fun _ -> queue_tail x l)
=
let hd = elim_queue_head x l in
let tl = llist_fragment_head_to_tail l (cllist_head x) hd in
intro_queue_tail x l tl
let queue_tail_to_head
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhostT unit opened
(queue_tail x l)
(fun _ -> queue_head x l)
=
let tl = elim_queue_tail x l in
let hd = llist_fragment_tail_to_head l (cllist_head x) tl in
intro_queue_head x l hd
(* We choose the head representation, since queue_is_empty and dequeue
need the head representation, but only enqueue needs the tail
representation. *)
[@@__reduce__]
let queue x l = queue_head x l
let create_queue a =
let head = ccell_ptrvalue_null a in
let tail : ref (ccell_ptrvalue a) = null in
let l0 = alloc_llist head tail in
let l = elim_cllist l0 in
write (cllist_tail l) (cllist_head l);
intro_llist_fragment_head_nil [] (cllist_head l) (Ghost.reveal (Ghost.hide head));
intro_queue_head l [] head;
let res : (t a & Ghost.erased (v a)) = (l0, Ghost.hide []) in
change_equal_slprop
(queue_head l [])
(queue (fst res) (snd res));
return res
let enqueue #a x l w =
queue_head_to_tail x l;
let ptail0 = elim_queue_tail x l in
let ptail = read (cllist_tail x) in
let c = alloc_cell w (ccell_ptrvalue_null a) in
let c0 = elim_ccell_ghost c in
change_equal_slprop
(vptr ptail0)
(vptr ptail);
write ptail c;
change_equal_slprop
(vptr ptail)
(vptr ptail0);
let l' = intro_llist_fragment_tail_snoc l (cllist_head x) ptail0 c0 in
write (cllist_tail x) (ccell_next c);
intro_queue_tail x l' (ccell_next c0);
queue_tail_to_head x l';
return l' | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: CQueue.t a -> l: FStar.Ghost.erased (CQueue.v a) -> Steel.Effect.Steel Prims.bool | Steel.Effect.Steel | [] | [] | [
"CQueue.t",
"FStar.Ghost.erased",
"CQueue.v",
"Steel.Effect.Atomic.return",
"Prims.bool",
"FStar.Ghost.hide",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.empty",
"Steel.Effect.Common.vdep",
"Steel.Reference.vptrp",
"CQueue.Cell.ccell_ptrvalue",
"CQueue.LList.cllist_head",
"Steel.FractionalPermission.full_perm",
"CQueue.queue_head_dep2",
"Steel.Effect.Common.vprop",
"Prims.unit",
"CQueue.intro_queue_head",
"CQueue.llist_fragment_head_is_nil",
"FStar.Ghost.reveal",
"CQueue.Cell.ccell_ptrvalue_is_null",
"Steel.Reference.read",
"CQueue.elim_queue_head"
] | [] | false | true | false | false | false | let queue_is_empty #a x l =
| let head0 = elim_queue_head x l in
let head = read (cllist_head x) in
let res = ccell_ptrvalue_is_null head in
llist_fragment_head_is_nil l (cllist_head x) head0;
intro_queue_head x l head0;
return res | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.state_inv_t | val state_inv_t: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> Type0 | val state_inv_t: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> Type0 | let state_inv_t #s h ctx =
felem_fits h (gsub ctx 0ul (nlimb s)) (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h (gsub ctx (nlimb s) (precomplen s)) | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 79,
"end_line": 54,
"start_col": 0,
"start_line": 52
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s)
unfold
let op_String_Access #a #len = LSeq.index #a #len
let as_get_acc #s h ctx = (feval h (gsub ctx 0ul (nlimb s))).[0]
let as_get_r #s h ctx = (feval h (gsub ctx (nlimb s) (nlimb s))).[0] | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> ctx: Hacl.Impl.Poly1305.poly1305_ctx s -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Poly1305.poly1305_ctx",
"Prims.l_and",
"Hacl.Impl.Poly1305.Fields.felem_fits",
"Lib.Buffer.gsub",
"Lib.Buffer.MUT",
"Hacl.Impl.Poly1305.Fields.limb",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Poly1305.Fields.nlimb",
"Hacl.Impl.Poly1305.Fields.precomplen",
"FStar.UInt32.__uint_to_t",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Hacl.Impl.Poly1305.Field32xN.load_precompute_r_post",
"Hacl.Impl.Poly1305.Fields.width"
] | [] | false | false | false | false | true | let state_inv_t #s h ctx =
| felem_fits h (gsub ctx 0ul (nlimb s)) (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h (gsub ctx (nlimb s) (precomplen s)) | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.as_get_r | val as_get_r: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> GTot S.felem | val as_get_r: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> GTot S.felem | let as_get_r #s h ctx = (feval h (gsub ctx (nlimb s) (nlimb s))).[0] | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 68,
"end_line": 50,
"start_col": 0,
"start_line": 50
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s)
unfold
let op_String_Access #a #len = LSeq.index #a #len
let as_get_acc #s h ctx = (feval h (gsub ctx 0ul (nlimb s))).[0] | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> ctx: Hacl.Impl.Poly1305.poly1305_ctx s
-> Prims.GTot Spec.Poly1305.felem | Prims.GTot | [
"sometrivial"
] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Poly1305.poly1305_ctx",
"Hacl.Impl.Poly1305.op_String_Access",
"Spec.Poly1305.felem",
"Hacl.Impl.Poly1305.Fields.width",
"Hacl.Impl.Poly1305.Fields.feval",
"Lib.Buffer.gsub",
"Lib.Buffer.MUT",
"Hacl.Impl.Poly1305.Fields.limb",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Poly1305.Fields.nlimb",
"Hacl.Impl.Poly1305.Fields.precomplen"
] | [] | false | false | false | false | false | let as_get_r #s h ctx =
| (feval h (gsub ctx (nlimb s) (nlimb s))).[ 0 ] | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.poly1305_update | val poly1305_update: #s:field_spec -> poly1305_update_st s | val poly1305_update: #s:field_spec -> poly1305_update_st s | let poly1305_update #s =
match s with
| M32 -> poly1305_update32
| _ -> poly1305_update_128_256 #s | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 35,
"end_line": 584,
"start_col": 0,
"start_line": 581
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s)
unfold
let op_String_Access #a #len = LSeq.index #a #len
let as_get_acc #s h ctx = (feval h (gsub ctx 0ul (nlimb s))).[0]
let as_get_r #s h ctx = (feval h (gsub ctx (nlimb s) (nlimb s))).[0]
let state_inv_t #s h ctx =
felem_fits h (gsub ctx 0ul (nlimb s)) (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h (gsub ctx (nlimb s) (precomplen s))
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --record_options"
let reveal_ctx_inv' #s ctx ctx' h0 h1 =
let acc_b = gsub ctx 0ul (nlimb s) in
let acc_b' = gsub ctx' 0ul (nlimb s) in
let r_b = gsub ctx (nlimb s) (nlimb s) in
let r_b' = gsub ctx' (nlimb s) (nlimb s) in
let precom_b = gsub ctx (nlimb s) (precomplen s) in
let precom_b' = gsub ctx' (nlimb s) (precomplen s) in
as_seq_gsub h0 ctx 0ul (nlimb s);
as_seq_gsub h1 ctx 0ul (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (nlimb s);
as_seq_gsub h1 ctx (nlimb s) (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (precomplen s);
as_seq_gsub h1 ctx (nlimb s) (precomplen s);
as_seq_gsub h0 ctx' 0ul (nlimb s);
as_seq_gsub h1 ctx' 0ul (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (nlimb s);
as_seq_gsub h1 ctx' (nlimb s) (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (precomplen s);
as_seq_gsub h1 ctx' (nlimb s) (precomplen s);
assert (as_seq h0 acc_b == as_seq h1 acc_b');
assert (as_seq h0 r_b == as_seq h1 r_b');
assert (as_seq h0 precom_b == as_seq h1 precom_b')
val fmul_precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.fmul_precomp_r_pre #(width s) h precomp_b)
let fmul_precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let r_b5 = gsub precomp_b (nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (nlimb s) (nlimb s);
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h r_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h r_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h r_b))
val precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.load_precompute_r_post #(width s) h precomp_b)
#push-options "--z3rlimit 150"
let precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let rn_b = gsub precomp_b (2ul *! nlimb s) (nlimb s) in
let rn_b5 = gsub precomp_b (3ul *! nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (2ul *! nlimb s) (nlimb s);
as_seq_gsub h precomp_b (3ul *! nlimb s) (nlimb s);
fmul_precomp_inv_zeros #s precomp_b h;
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h rn_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h rn_b));
assert (feval h rn_b == Vec.compute_rw (feval h r_b).[0])
#pop-options
let ctx_inv_zeros #s ctx h =
// ctx = [acc_b; r_b; r_b5; rn_b; rn_b5]
let acc_b = gsub ctx 0ul (nlimb s) in
as_seq_gsub h ctx 0ul (nlimb s);
LSeq.eq_intro (feval h acc_b) (LSeq.create (width s) 0);
assert (felem_fits h acc_b (2, 2, 2, 2, 2));
let precomp_b = gsub ctx (nlimb s) (precomplen s) in
LSeq.eq_intro (as_seq h precomp_b) (Lib.Sequence.create (v (precomplen s)) (limb_zero s));
precomp_inv_zeros #s precomp_b h
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
val poly1305_encode_block:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode 16 (as_seq h0 b))
let poly1305_encode_block #s f b =
load_felem_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_blocks:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 (blocklen s) ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
feval h1 f == Vec.load_blocks #(width s) (as_seq h0 b))
let poly1305_encode_blocks #s f b =
load_felems_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_last:
#s:field_spec
-> f:felem s
-> len:size_t{v len < 16}
-> b:lbuffer uint8 len ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode (v len) (as_seq h0 b))
let poly1305_encode_last #s f len b =
push_frame();
let tmp = create 16ul (u8 0) in
update_sub tmp 0ul len b;
let h0 = ST.get () in
Hacl.Impl.Poly1305.Lemmas.nat_from_bytes_le_eq_lemma (v len) (as_seq h0 b);
assert (BSeq.nat_from_bytes_le (as_seq h0 b) == BSeq.nat_from_bytes_le (as_seq h0 tmp));
assert (BSeq.nat_from_bytes_le (as_seq h0 b) < pow2 (v len * 8));
load_felem_le f tmp;
let h1 = ST.get () in
lemma_feval_is_fas_nat h1 f;
set_bit f (len *! 8ul);
pop_frame()
inline_for_extraction noextract
val poly1305_encode_r:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h p /\ disjoint b p)
(ensures fun h0 _ h1 ->
modifies (loc p) h0 h1 /\
F32xN.load_precompute_r_post #(width s) h1 p /\
(feval h1 (gsub p 0ul 5ul)).[0] == S.poly1305_encode_r (as_seq h0 b))
let poly1305_encode_r #s p b =
let lo = uint_from_bytes_le (sub b 0ul 8ul) in
let hi = uint_from_bytes_le (sub b 8ul 8ul) in
let mask0 = u64 0x0ffffffc0fffffff in
let mask1 = u64 0x0ffffffc0ffffffc in
let lo = lo &. mask0 in
let hi = hi &. mask1 in
load_precompute_r p lo hi
[@ Meta.Attribute.specialize ]
let poly1305_init #s ctx key =
let acc = get_acc ctx in
let pre = get_precomp_r ctx in
let kr = sub key 0ul 16ul in
set_zero acc;
poly1305_encode_r #s pre kr
inline_for_extraction noextract
val update1:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 16ul
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h b /\ live h acc /\
disjoint p acc /\ disjoint b acc /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] == S.poly1305_update1
(feval h0 (gsub p 0ul 5ul)).[0] 16 (as_seq h0 b) (feval h0 acc).[0])
let update1 #s pre b acc =
push_frame ();
let e = create (nlimb s) (limb_zero s) in
poly1305_encode_block e b;
fadd_mul_r acc e pre;
pop_frame ()
let poly1305_update1 #s ctx text =
let pre = get_precomp_r ctx in
let acc = get_acc ctx in
update1 pre text acc
inline_for_extraction noextract
val poly1305_update_last:
#s:field_spec
-> p:precomp_r s
-> len:size_t{v len < 16}
-> b:lbuffer uint8 len
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h b /\ live h acc /\
disjoint p acc /\ disjoint b acc /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] == S.poly1305_update1
(feval h0 (gsub p 0ul 5ul)).[0] (v len) (as_seq h0 b) (feval h0 acc).[0])
#push-options "--z3rlimit 200"
let poly1305_update_last #s pre len b acc =
push_frame ();
let e = create (nlimb s) (limb_zero s) in
poly1305_encode_last e len b;
fadd_mul_r acc e pre;
pop_frame ()
#pop-options
inline_for_extraction noextract
val poly1305_update_nblocks:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 (blocklen s)
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h b /\ live h acc /\
disjoint acc p /\ disjoint acc b /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
feval h1 acc ==
Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub p 10ul 5ul)) (as_seq h0 b) (feval h0 acc))
let poly1305_update_nblocks #s pre b acc =
push_frame ();
let e = create (nlimb s) (limb_zero s) in
poly1305_encode_blocks e b;
fmul_rn acc acc pre;
fadd acc acc e;
pop_frame ()
inline_for_extraction noextract
val poly1305_update1_f:
#s:field_spec
-> p:precomp_r s
-> nb:size_t
-> len:size_t{v nb == v len / 16}
-> text:lbuffer uint8 len
-> i:size_t{v i < v nb}
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h text /\ live h acc /\
disjoint acc p /\ disjoint acc text /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
LSeq.repeat_blocks_f #uint8 #S.felem 16
(as_seq h0 text) (S.poly1305_update1 (feval h0 (gsub p 0ul 5ul)).[0] 16) (v nb) (v i) (feval h0 acc).[0])
let poly1305_update1_f #s pre nb len text i acc=
assert ((v i + 1) * 16 <= v nb * 16);
let block = sub #_ #_ #len text (i *! 16ul) 16ul in
update1 #s pre block acc
#push-options "--z3rlimit 100 --max_fuel 1"
inline_for_extraction noextract
val poly1305_update_scalar:
#s:field_spec
-> len:size_t
-> text:lbuffer uint8 len
-> pre:precomp_r s
-> acc:felem s ->
Stack unit
(requires fun h ->
live h text /\ live h acc /\ live h pre /\
disjoint acc text /\ disjoint acc pre /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h pre)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
S.poly1305_update (as_seq h0 text) (feval h0 acc).[0] (feval h0 (gsub pre 0ul 5ul)).[0])
let poly1305_update_scalar #s len text pre acc =
let nb = len /. 16ul in
let rem = len %. 16ul in
let h0 = ST.get () in
LSeq.lemma_repeat_blocks #uint8 #S.felem 16 (as_seq h0 text)
(S.poly1305_update1 (feval h0 (gsub pre 0ul 5ul)).[0] 16)
(S.poly1305_update_last (feval h0 (gsub pre 0ul 5ul)).[0])
(feval h0 acc).[0];
[@ inline_let]
let spec_fh h0 =
LSeq.repeat_blocks_f 16 (as_seq h0 text)
(S.poly1305_update1 (feval h0 (gsub pre 0ul 5ul)).[0] 16) (v nb) in
[@ inline_let]
let inv h (i:nat{i <= v nb}) =
modifies1 acc h0 h /\
live h pre /\ live h text /\ live h acc /\
disjoint acc pre /\ disjoint acc text /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h pre /\
(feval h acc).[0] == Lib.LoopCombinators.repeati i (spec_fh h0) (feval h0 acc).[0] in
Lib.Loops.for (size 0) nb inv
(fun i ->
Lib.LoopCombinators.unfold_repeati (v nb) (spec_fh h0) (feval h0 acc).[0] (v i);
poly1305_update1_f #s pre nb len text i acc);
let h1 = ST.get () in
assert ((feval h1 acc).[0] == Lib.LoopCombinators.repeati (v nb) (spec_fh h0) (feval h0 acc).[0]);
if rem >. 0ul then (
let last = sub text (nb *! 16ul) rem in
as_seq_gsub h1 text (nb *! 16ul) rem;
assert (disjoint acc last);
poly1305_update_last #s pre rem last acc)
#pop-options
inline_for_extraction noextract
val poly1305_update_multi_f:
#s:field_spec
-> p:precomp_r s
-> bs:size_t{v bs == width s * S.size_block}
-> nb:size_t
-> len:size_t{v nb == v len / v bs /\ v len % v bs == 0}
-> text:lbuffer uint8 len
-> i:size_t{v i < v nb}
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h text /\ live h acc /\
disjoint acc p /\ disjoint acc text /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h1 p /\
feval h1 acc ==
LSeq.repeat_blocks_f #uint8 #(Vec.elem (width s))
(v bs) (as_seq h0 text) (Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub p 10ul 5ul))) (v nb) (v i) (feval h0 acc))
let poly1305_update_multi_f #s pre bs nb len text i acc=
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub #_ #_ #len text (i *! bs) bs in
let h1 = ST.get () in
as_seq_gsub h1 text (i *! bs) bs;
poly1305_update_nblocks #s pre block acc
#push-options "--max_fuel 1"
inline_for_extraction noextract
val poly1305_update_multi_loop:
#s:field_spec
-> bs:size_t{v bs == width s * S.size_block}
-> len:size_t{v len % v (blocklen s) == 0}
-> text:lbuffer uint8 len
-> pre:precomp_r s
-> acc:felem s ->
Stack unit
(requires fun h ->
live h pre /\ live h acc /\ live h text /\
disjoint acc text /\ disjoint acc pre /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h pre)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h1 pre /\
feval h1 acc == LSeq.repeat_blocks_multi #uint8 #(Vec.elem (width s)) (v bs) (as_seq h0 text)
(Vec.poly1305_update_nblocks (feval h0 (gsub pre 10ul 5ul))) (feval h0 acc))
let poly1305_update_multi_loop #s bs len text pre acc =
let nb = len /. bs in
let h0 = ST.get () in
LSeq.lemma_repeat_blocks_multi #uint8 #(Vec.elem (width s)) (v bs) (as_seq h0 text)
(Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub pre 10ul 5ul))) (feval h0 acc);
[@ inline_let]
let spec_fh h0 =
LSeq.repeat_blocks_f (v bs) (as_seq h0 text)
(Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub pre 10ul 5ul))) (v nb) in
[@ inline_let]
let inv h (i:nat{i <= v nb}) =
modifies1 acc h0 h /\
live h pre /\ live h text /\ live h acc /\
disjoint acc pre /\ disjoint acc text /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h pre /\
feval h acc == Lib.LoopCombinators.repeati i (spec_fh h0) (feval h0 acc) in
Lib.Loops.for (size 0) nb inv
(fun i ->
Lib.LoopCombinators.unfold_repeati (v nb) (spec_fh h0) (feval h0 acc) (v i);
poly1305_update_multi_f #s pre bs nb len text i acc)
#pop-options
#push-options "--z3rlimit 350"
inline_for_extraction noextract
val poly1305_update_multi:
#s:field_spec
-> len:size_t{0 < v len /\ v len % v (blocklen s) == 0}
-> text:lbuffer uint8 len
-> pre:precomp_r s
-> acc:felem s ->
Stack unit
(requires fun h ->
live h pre /\ live h acc /\ live h text /\
disjoint acc text /\ disjoint acc pre /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h pre)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
Vec.poly1305_update_multi #(width s) (as_seq h0 text)
(feval h0 acc).[0] (feval h0 (gsub pre 0ul 5ul)).[0])
let poly1305_update_multi #s len text pre acc =
let h0 = ST.get () in
assert_norm (v 10ul + v 5ul <= v 20ul);
assert (feval h0 (gsub pre 10ul 5ul) == Vec.compute_rw #(width s) ((feval h0 (gsub pre 0ul 5ul)).[0]));
let bs = blocklen s in
//assert (v bs == width s * S.size_block);
let text0 = sub text 0ul bs in
load_acc #s acc text0;
let len1 = len -! bs in
let text1 = sub text bs len1 in
poly1305_update_multi_loop #s bs len1 text1 pre acc;
fmul_rn_normalize acc pre
#pop-options
inline_for_extraction noextract
val poly1305_update_vec:
#s:field_spec
-> len:size_t
-> text:lbuffer uint8 len
-> pre:precomp_r s
-> acc:felem s ->
Stack unit
(requires fun h ->
live h text /\ live h acc /\ live h pre /\
disjoint acc text /\ disjoint acc pre /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h pre)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
Vec.poly1305_update_vec #(width s) (as_seq h0 text) (feval h0 acc).[0] (feval h0 (gsub pre 0ul 5ul)).[0])
let poly1305_update_vec #s len text pre acc =
let sz_block = blocklen s in
FStar.Math.Lemmas.multiply_fractions (v len) (v sz_block);
let len0 = (len /. sz_block) *! sz_block in
let t0 = sub text 0ul len0 in
FStar.Math.Lemmas.multiple_modulo_lemma (v (len /. sz_block)) (v (blocklen s));
if len0 >. 0ul then poly1305_update_multi len0 t0 pre acc;
let len1 = len -! len0 in
let t1 = sub text len0 len1 in
poly1305_update_scalar #s len1 t1 pre acc
inline_for_extraction noextract
val poly1305_update32: poly1305_update_st M32
let poly1305_update32 ctx len text =
let pre = get_precomp_r ctx in
let acc = get_acc ctx in
poly1305_update_scalar #M32 len text pre acc
inline_for_extraction noextract
val poly1305_update_128_256: #s:field_spec { s = M128 || s = M256 } -> poly1305_update_st s
let poly1305_update_128_256 #s ctx len text =
let pre = get_precomp_r ctx in
let acc = get_acc ctx in
let h0 = ST.get () in
poly1305_update_vec #s len text pre acc;
let h1 = ST.get () in
Equiv.poly1305_update_vec_lemma #(width s) (as_seq h0 text) (feval h0 acc).[0] (feval h0 (gsub pre 0ul 5ul)).[0]
inline_for_extraction noextract | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Hacl.Impl.Poly1305.poly1305_update_st s | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"Hacl.Impl.Poly1305.poly1305_update32",
"Hacl.Impl.Poly1305.poly1305_update_128_256",
"Hacl.Impl.Poly1305.poly1305_update_st"
] | [] | false | false | false | false | false | let poly1305_update #s =
| match s with
| M32 -> poly1305_update32
| _ -> poly1305_update_128_256 #s | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.as_get_acc | val as_get_acc: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> GTot S.felem | val as_get_acc: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> GTot S.felem | let as_get_acc #s h ctx = (feval h (gsub ctx 0ul (nlimb s))).[0] | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 64,
"end_line": 48,
"start_col": 0,
"start_line": 48
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s)
unfold
let op_String_Access #a #len = LSeq.index #a #len | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> ctx: Hacl.Impl.Poly1305.poly1305_ctx s
-> Prims.GTot Spec.Poly1305.felem | Prims.GTot | [
"sometrivial"
] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Poly1305.poly1305_ctx",
"Hacl.Impl.Poly1305.op_String_Access",
"Spec.Poly1305.felem",
"Hacl.Impl.Poly1305.Fields.width",
"Hacl.Impl.Poly1305.Fields.feval",
"Lib.Buffer.gsub",
"Lib.Buffer.MUT",
"Hacl.Impl.Poly1305.Fields.limb",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Poly1305.Fields.nlimb",
"Hacl.Impl.Poly1305.Fields.precomplen",
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | false | false | let as_get_acc #s h ctx =
| (feval h (gsub ctx 0ul (nlimb s))).[ 0 ] | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.get_precomp_r | val get_precomp_r (#s: _) (ctx: poly1305_ctx s)
: Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s)) | val get_precomp_r (#s: _) (ctx: poly1305_ctx s)
: Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s)) | let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s) | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 36,
"end_line": 42,
"start_col": 0,
"start_line": 39
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s) | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ctx: Hacl.Impl.Poly1305.poly1305_ctx s
-> FStar.HyperStack.ST.Stack (Hacl.Impl.Poly1305.Fields.precomp_r s) | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"Hacl.Impl.Poly1305.poly1305_ctx",
"Lib.Buffer.sub",
"Lib.Buffer.MUT",
"Hacl.Impl.Poly1305.Fields.limb",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Poly1305.Fields.nlimb",
"Hacl.Impl.Poly1305.Fields.precomplen",
"Lib.Buffer.lbuffer_t",
"Hacl.Impl.Poly1305.Fields.precomp_r",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Prims.l_and",
"Prims.eq2",
"Lib.Buffer.gsub"
] | [] | false | true | false | false | false | let get_precomp_r #s (ctx: poly1305_ctx s)
: Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s)) =
| sub ctx (nlimb s) (precomplen s) | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.poly1305_encode_block | val poly1305_encode_block:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode 16 (as_seq h0 b)) | val poly1305_encode_block:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode 16 (as_seq h0 b)) | let poly1305_encode_block #s f b =
load_felem_le f b;
set_bit128 f | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 152,
"start_col": 0,
"start_line": 150
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s)
unfold
let op_String_Access #a #len = LSeq.index #a #len
let as_get_acc #s h ctx = (feval h (gsub ctx 0ul (nlimb s))).[0]
let as_get_r #s h ctx = (feval h (gsub ctx (nlimb s) (nlimb s))).[0]
let state_inv_t #s h ctx =
felem_fits h (gsub ctx 0ul (nlimb s)) (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h (gsub ctx (nlimb s) (precomplen s))
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --record_options"
let reveal_ctx_inv' #s ctx ctx' h0 h1 =
let acc_b = gsub ctx 0ul (nlimb s) in
let acc_b' = gsub ctx' 0ul (nlimb s) in
let r_b = gsub ctx (nlimb s) (nlimb s) in
let r_b' = gsub ctx' (nlimb s) (nlimb s) in
let precom_b = gsub ctx (nlimb s) (precomplen s) in
let precom_b' = gsub ctx' (nlimb s) (precomplen s) in
as_seq_gsub h0 ctx 0ul (nlimb s);
as_seq_gsub h1 ctx 0ul (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (nlimb s);
as_seq_gsub h1 ctx (nlimb s) (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (precomplen s);
as_seq_gsub h1 ctx (nlimb s) (precomplen s);
as_seq_gsub h0 ctx' 0ul (nlimb s);
as_seq_gsub h1 ctx' 0ul (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (nlimb s);
as_seq_gsub h1 ctx' (nlimb s) (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (precomplen s);
as_seq_gsub h1 ctx' (nlimb s) (precomplen s);
assert (as_seq h0 acc_b == as_seq h1 acc_b');
assert (as_seq h0 r_b == as_seq h1 r_b');
assert (as_seq h0 precom_b == as_seq h1 precom_b')
val fmul_precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.fmul_precomp_r_pre #(width s) h precomp_b)
let fmul_precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let r_b5 = gsub precomp_b (nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (nlimb s) (nlimb s);
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h r_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h r_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h r_b))
val precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.load_precompute_r_post #(width s) h precomp_b)
#push-options "--z3rlimit 150"
let precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let rn_b = gsub precomp_b (2ul *! nlimb s) (nlimb s) in
let rn_b5 = gsub precomp_b (3ul *! nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (2ul *! nlimb s) (nlimb s);
as_seq_gsub h precomp_b (3ul *! nlimb s) (nlimb s);
fmul_precomp_inv_zeros #s precomp_b h;
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h rn_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h rn_b));
assert (feval h rn_b == Vec.compute_rw (feval h r_b).[0])
#pop-options
let ctx_inv_zeros #s ctx h =
// ctx = [acc_b; r_b; r_b5; rn_b; rn_b5]
let acc_b = gsub ctx 0ul (nlimb s) in
as_seq_gsub h ctx 0ul (nlimb s);
LSeq.eq_intro (feval h acc_b) (LSeq.create (width s) 0);
assert (felem_fits h acc_b (2, 2, 2, 2, 2));
let precomp_b = gsub ctx (nlimb s) (precomplen s) in
LSeq.eq_intro (as_seq h precomp_b) (Lib.Sequence.create (v (precomplen s)) (limb_zero s));
precomp_inv_zeros #s precomp_b h
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
val poly1305_encode_block:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode 16 (as_seq h0 b)) | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | f: Hacl.Impl.Poly1305.Fields.felem s -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 16ul
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"Hacl.Impl.Poly1305.Fields.felem",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Poly1305.Fields.set_bit128",
"Prims.unit",
"Hacl.Impl.Poly1305.Fields.load_felem_le"
] | [] | false | true | false | false | false | let poly1305_encode_block #s f b =
| load_felem_le f b;
set_bit128 f | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.get_acc | val get_acc (#s: _) (ctx: poly1305_ctx s)
: Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s)) | val get_acc (#s: _) (ctx: poly1305_ctx s)
: Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s)) | let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s) | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 35,
"start_col": 0,
"start_line": 32
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options" | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ctx: Hacl.Impl.Poly1305.poly1305_ctx s
-> FStar.HyperStack.ST.Stack (Hacl.Impl.Poly1305.Fields.felem s) | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"Hacl.Impl.Poly1305.poly1305_ctx",
"Lib.Buffer.sub",
"Lib.Buffer.MUT",
"Hacl.Impl.Poly1305.Fields.limb",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Poly1305.Fields.nlimb",
"Hacl.Impl.Poly1305.Fields.precomplen",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.lbuffer_t",
"Hacl.Impl.Poly1305.Fields.felem",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Prims.l_and",
"Prims.eq2",
"Lib.Buffer.gsub"
] | [] | false | true | false | false | false | let get_acc #s (ctx: poly1305_ctx s)
: Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s)) =
| sub ctx 0ul (nlimb s) | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.poly1305_encode_blocks | val poly1305_encode_blocks:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 (blocklen s) ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
feval h1 f == Vec.load_blocks #(width s) (as_seq h0 b)) | val poly1305_encode_blocks:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 (blocklen s) ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
feval h1 f == Vec.load_blocks #(width s) (as_seq h0 b)) | let poly1305_encode_blocks #s f b =
load_felems_le f b;
set_bit128 f | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 170,
"start_col": 0,
"start_line": 168
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s)
unfold
let op_String_Access #a #len = LSeq.index #a #len
let as_get_acc #s h ctx = (feval h (gsub ctx 0ul (nlimb s))).[0]
let as_get_r #s h ctx = (feval h (gsub ctx (nlimb s) (nlimb s))).[0]
let state_inv_t #s h ctx =
felem_fits h (gsub ctx 0ul (nlimb s)) (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h (gsub ctx (nlimb s) (precomplen s))
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --record_options"
let reveal_ctx_inv' #s ctx ctx' h0 h1 =
let acc_b = gsub ctx 0ul (nlimb s) in
let acc_b' = gsub ctx' 0ul (nlimb s) in
let r_b = gsub ctx (nlimb s) (nlimb s) in
let r_b' = gsub ctx' (nlimb s) (nlimb s) in
let precom_b = gsub ctx (nlimb s) (precomplen s) in
let precom_b' = gsub ctx' (nlimb s) (precomplen s) in
as_seq_gsub h0 ctx 0ul (nlimb s);
as_seq_gsub h1 ctx 0ul (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (nlimb s);
as_seq_gsub h1 ctx (nlimb s) (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (precomplen s);
as_seq_gsub h1 ctx (nlimb s) (precomplen s);
as_seq_gsub h0 ctx' 0ul (nlimb s);
as_seq_gsub h1 ctx' 0ul (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (nlimb s);
as_seq_gsub h1 ctx' (nlimb s) (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (precomplen s);
as_seq_gsub h1 ctx' (nlimb s) (precomplen s);
assert (as_seq h0 acc_b == as_seq h1 acc_b');
assert (as_seq h0 r_b == as_seq h1 r_b');
assert (as_seq h0 precom_b == as_seq h1 precom_b')
val fmul_precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.fmul_precomp_r_pre #(width s) h precomp_b)
let fmul_precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let r_b5 = gsub precomp_b (nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (nlimb s) (nlimb s);
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h r_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h r_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h r_b))
val precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.load_precompute_r_post #(width s) h precomp_b)
#push-options "--z3rlimit 150"
let precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let rn_b = gsub precomp_b (2ul *! nlimb s) (nlimb s) in
let rn_b5 = gsub precomp_b (3ul *! nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (2ul *! nlimb s) (nlimb s);
as_seq_gsub h precomp_b (3ul *! nlimb s) (nlimb s);
fmul_precomp_inv_zeros #s precomp_b h;
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h rn_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h rn_b));
assert (feval h rn_b == Vec.compute_rw (feval h r_b).[0])
#pop-options
let ctx_inv_zeros #s ctx h =
// ctx = [acc_b; r_b; r_b5; rn_b; rn_b5]
let acc_b = gsub ctx 0ul (nlimb s) in
as_seq_gsub h ctx 0ul (nlimb s);
LSeq.eq_intro (feval h acc_b) (LSeq.create (width s) 0);
assert (felem_fits h acc_b (2, 2, 2, 2, 2));
let precomp_b = gsub ctx (nlimb s) (precomplen s) in
LSeq.eq_intro (as_seq h precomp_b) (Lib.Sequence.create (v (precomplen s)) (limb_zero s));
precomp_inv_zeros #s precomp_b h
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
val poly1305_encode_block:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode 16 (as_seq h0 b))
let poly1305_encode_block #s f b =
load_felem_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_blocks:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 (blocklen s) ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
feval h1 f == Vec.load_blocks #(width s) (as_seq h0 b)) | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
f: Hacl.Impl.Poly1305.Fields.felem s ->
b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.Impl.Poly1305.Fields.blocklen s)
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"Hacl.Impl.Poly1305.Fields.felem",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Hacl.Impl.Poly1305.Fields.blocklen",
"Hacl.Impl.Poly1305.Fields.set_bit128",
"Prims.unit",
"Hacl.Impl.Poly1305.Fields.load_felems_le"
] | [] | false | true | false | false | false | let poly1305_encode_blocks #s f b =
| load_felems_le f b;
set_bit128 f | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.poly1305_encode_r | val poly1305_encode_r:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h p /\ disjoint b p)
(ensures fun h0 _ h1 ->
modifies (loc p) h0 h1 /\
F32xN.load_precompute_r_post #(width s) h1 p /\
(feval h1 (gsub p 0ul 5ul)).[0] == S.poly1305_encode_r (as_seq h0 b)) | val poly1305_encode_r:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h p /\ disjoint b p)
(ensures fun h0 _ h1 ->
modifies (loc p) h0 h1 /\
F32xN.load_precompute_r_post #(width s) h1 p /\
(feval h1 (gsub p 0ul 5ul)).[0] == S.poly1305_encode_r (as_seq h0 b)) | let poly1305_encode_r #s p b =
let lo = uint_from_bytes_le (sub b 0ul 8ul) in
let hi = uint_from_bytes_le (sub b 8ul 8ul) in
let mask0 = u64 0x0ffffffc0fffffff in
let mask1 = u64 0x0ffffffc0ffffffc in
let lo = lo &. mask0 in
let hi = hi &. mask1 in
load_precompute_r p lo hi | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 223,
"start_col": 0,
"start_line": 216
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s)
unfold
let op_String_Access #a #len = LSeq.index #a #len
let as_get_acc #s h ctx = (feval h (gsub ctx 0ul (nlimb s))).[0]
let as_get_r #s h ctx = (feval h (gsub ctx (nlimb s) (nlimb s))).[0]
let state_inv_t #s h ctx =
felem_fits h (gsub ctx 0ul (nlimb s)) (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h (gsub ctx (nlimb s) (precomplen s))
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --record_options"
let reveal_ctx_inv' #s ctx ctx' h0 h1 =
let acc_b = gsub ctx 0ul (nlimb s) in
let acc_b' = gsub ctx' 0ul (nlimb s) in
let r_b = gsub ctx (nlimb s) (nlimb s) in
let r_b' = gsub ctx' (nlimb s) (nlimb s) in
let precom_b = gsub ctx (nlimb s) (precomplen s) in
let precom_b' = gsub ctx' (nlimb s) (precomplen s) in
as_seq_gsub h0 ctx 0ul (nlimb s);
as_seq_gsub h1 ctx 0ul (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (nlimb s);
as_seq_gsub h1 ctx (nlimb s) (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (precomplen s);
as_seq_gsub h1 ctx (nlimb s) (precomplen s);
as_seq_gsub h0 ctx' 0ul (nlimb s);
as_seq_gsub h1 ctx' 0ul (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (nlimb s);
as_seq_gsub h1 ctx' (nlimb s) (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (precomplen s);
as_seq_gsub h1 ctx' (nlimb s) (precomplen s);
assert (as_seq h0 acc_b == as_seq h1 acc_b');
assert (as_seq h0 r_b == as_seq h1 r_b');
assert (as_seq h0 precom_b == as_seq h1 precom_b')
val fmul_precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.fmul_precomp_r_pre #(width s) h precomp_b)
let fmul_precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let r_b5 = gsub precomp_b (nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (nlimb s) (nlimb s);
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h r_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h r_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h r_b))
val precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.load_precompute_r_post #(width s) h precomp_b)
#push-options "--z3rlimit 150"
let precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let rn_b = gsub precomp_b (2ul *! nlimb s) (nlimb s) in
let rn_b5 = gsub precomp_b (3ul *! nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (2ul *! nlimb s) (nlimb s);
as_seq_gsub h precomp_b (3ul *! nlimb s) (nlimb s);
fmul_precomp_inv_zeros #s precomp_b h;
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h rn_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h rn_b));
assert (feval h rn_b == Vec.compute_rw (feval h r_b).[0])
#pop-options
let ctx_inv_zeros #s ctx h =
// ctx = [acc_b; r_b; r_b5; rn_b; rn_b5]
let acc_b = gsub ctx 0ul (nlimb s) in
as_seq_gsub h ctx 0ul (nlimb s);
LSeq.eq_intro (feval h acc_b) (LSeq.create (width s) 0);
assert (felem_fits h acc_b (2, 2, 2, 2, 2));
let precomp_b = gsub ctx (nlimb s) (precomplen s) in
LSeq.eq_intro (as_seq h precomp_b) (Lib.Sequence.create (v (precomplen s)) (limb_zero s));
precomp_inv_zeros #s precomp_b h
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
val poly1305_encode_block:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode 16 (as_seq h0 b))
let poly1305_encode_block #s f b =
load_felem_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_blocks:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 (blocklen s) ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
feval h1 f == Vec.load_blocks #(width s) (as_seq h0 b))
let poly1305_encode_blocks #s f b =
load_felems_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_last:
#s:field_spec
-> f:felem s
-> len:size_t{v len < 16}
-> b:lbuffer uint8 len ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode (v len) (as_seq h0 b))
let poly1305_encode_last #s f len b =
push_frame();
let tmp = create 16ul (u8 0) in
update_sub tmp 0ul len b;
let h0 = ST.get () in
Hacl.Impl.Poly1305.Lemmas.nat_from_bytes_le_eq_lemma (v len) (as_seq h0 b);
assert (BSeq.nat_from_bytes_le (as_seq h0 b) == BSeq.nat_from_bytes_le (as_seq h0 tmp));
assert (BSeq.nat_from_bytes_le (as_seq h0 b) < pow2 (v len * 8));
load_felem_le f tmp;
let h1 = ST.get () in
lemma_feval_is_fas_nat h1 f;
set_bit f (len *! 8ul);
pop_frame()
inline_for_extraction noextract
val poly1305_encode_r:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h p /\ disjoint b p)
(ensures fun h0 _ h1 ->
modifies (loc p) h0 h1 /\
F32xN.load_precompute_r_post #(width s) h1 p /\
(feval h1 (gsub p 0ul 5ul)).[0] == S.poly1305_encode_r (as_seq h0 b)) | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.Poly1305.Fields.precomp_r s -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 16ul
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"Hacl.Impl.Poly1305.Fields.precomp_r",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Poly1305.Fields.load_precompute_r",
"Prims.unit",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Amp_Dot",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.v",
"Lib.IntTypes.u64",
"Lib.ByteBuffer.uint_from_bytes_le",
"Lib.IntTypes.uint_t",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.U8",
"Lib.IntTypes.mk_int",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.sub"
] | [] | false | true | false | false | false | let poly1305_encode_r #s p b =
| let lo = uint_from_bytes_le (sub b 0ul 8ul) in
let hi = uint_from_bytes_le (sub b 8ul 8ul) in
let mask0 = u64 0x0ffffffc0fffffff in
let mask1 = u64 0x0ffffffc0ffffffc in
let lo = lo &. mask0 in
let hi = hi &. mask1 in
load_precompute_r p lo hi | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.poly1305_update32 | val poly1305_update32: poly1305_update_st M32 | val poly1305_update32: poly1305_update_st M32 | let poly1305_update32 ctx len text =
let pre = get_precomp_r ctx in
let acc = get_acc ctx in
poly1305_update_scalar #M32 len text pre acc | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 565,
"start_col": 0,
"start_line": 562
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s)
unfold
let op_String_Access #a #len = LSeq.index #a #len
let as_get_acc #s h ctx = (feval h (gsub ctx 0ul (nlimb s))).[0]
let as_get_r #s h ctx = (feval h (gsub ctx (nlimb s) (nlimb s))).[0]
let state_inv_t #s h ctx =
felem_fits h (gsub ctx 0ul (nlimb s)) (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h (gsub ctx (nlimb s) (precomplen s))
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --record_options"
let reveal_ctx_inv' #s ctx ctx' h0 h1 =
let acc_b = gsub ctx 0ul (nlimb s) in
let acc_b' = gsub ctx' 0ul (nlimb s) in
let r_b = gsub ctx (nlimb s) (nlimb s) in
let r_b' = gsub ctx' (nlimb s) (nlimb s) in
let precom_b = gsub ctx (nlimb s) (precomplen s) in
let precom_b' = gsub ctx' (nlimb s) (precomplen s) in
as_seq_gsub h0 ctx 0ul (nlimb s);
as_seq_gsub h1 ctx 0ul (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (nlimb s);
as_seq_gsub h1 ctx (nlimb s) (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (precomplen s);
as_seq_gsub h1 ctx (nlimb s) (precomplen s);
as_seq_gsub h0 ctx' 0ul (nlimb s);
as_seq_gsub h1 ctx' 0ul (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (nlimb s);
as_seq_gsub h1 ctx' (nlimb s) (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (precomplen s);
as_seq_gsub h1 ctx' (nlimb s) (precomplen s);
assert (as_seq h0 acc_b == as_seq h1 acc_b');
assert (as_seq h0 r_b == as_seq h1 r_b');
assert (as_seq h0 precom_b == as_seq h1 precom_b')
val fmul_precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.fmul_precomp_r_pre #(width s) h precomp_b)
let fmul_precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let r_b5 = gsub precomp_b (nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (nlimb s) (nlimb s);
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h r_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h r_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h r_b))
val precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.load_precompute_r_post #(width s) h precomp_b)
#push-options "--z3rlimit 150"
let precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let rn_b = gsub precomp_b (2ul *! nlimb s) (nlimb s) in
let rn_b5 = gsub precomp_b (3ul *! nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (2ul *! nlimb s) (nlimb s);
as_seq_gsub h precomp_b (3ul *! nlimb s) (nlimb s);
fmul_precomp_inv_zeros #s precomp_b h;
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h rn_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h rn_b));
assert (feval h rn_b == Vec.compute_rw (feval h r_b).[0])
#pop-options
let ctx_inv_zeros #s ctx h =
// ctx = [acc_b; r_b; r_b5; rn_b; rn_b5]
let acc_b = gsub ctx 0ul (nlimb s) in
as_seq_gsub h ctx 0ul (nlimb s);
LSeq.eq_intro (feval h acc_b) (LSeq.create (width s) 0);
assert (felem_fits h acc_b (2, 2, 2, 2, 2));
let precomp_b = gsub ctx (nlimb s) (precomplen s) in
LSeq.eq_intro (as_seq h precomp_b) (Lib.Sequence.create (v (precomplen s)) (limb_zero s));
precomp_inv_zeros #s precomp_b h
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
val poly1305_encode_block:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode 16 (as_seq h0 b))
let poly1305_encode_block #s f b =
load_felem_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_blocks:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 (blocklen s) ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
feval h1 f == Vec.load_blocks #(width s) (as_seq h0 b))
let poly1305_encode_blocks #s f b =
load_felems_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_last:
#s:field_spec
-> f:felem s
-> len:size_t{v len < 16}
-> b:lbuffer uint8 len ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode (v len) (as_seq h0 b))
let poly1305_encode_last #s f len b =
push_frame();
let tmp = create 16ul (u8 0) in
update_sub tmp 0ul len b;
let h0 = ST.get () in
Hacl.Impl.Poly1305.Lemmas.nat_from_bytes_le_eq_lemma (v len) (as_seq h0 b);
assert (BSeq.nat_from_bytes_le (as_seq h0 b) == BSeq.nat_from_bytes_le (as_seq h0 tmp));
assert (BSeq.nat_from_bytes_le (as_seq h0 b) < pow2 (v len * 8));
load_felem_le f tmp;
let h1 = ST.get () in
lemma_feval_is_fas_nat h1 f;
set_bit f (len *! 8ul);
pop_frame()
inline_for_extraction noextract
val poly1305_encode_r:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h p /\ disjoint b p)
(ensures fun h0 _ h1 ->
modifies (loc p) h0 h1 /\
F32xN.load_precompute_r_post #(width s) h1 p /\
(feval h1 (gsub p 0ul 5ul)).[0] == S.poly1305_encode_r (as_seq h0 b))
let poly1305_encode_r #s p b =
let lo = uint_from_bytes_le (sub b 0ul 8ul) in
let hi = uint_from_bytes_le (sub b 8ul 8ul) in
let mask0 = u64 0x0ffffffc0fffffff in
let mask1 = u64 0x0ffffffc0ffffffc in
let lo = lo &. mask0 in
let hi = hi &. mask1 in
load_precompute_r p lo hi
[@ Meta.Attribute.specialize ]
let poly1305_init #s ctx key =
let acc = get_acc ctx in
let pre = get_precomp_r ctx in
let kr = sub key 0ul 16ul in
set_zero acc;
poly1305_encode_r #s pre kr
inline_for_extraction noextract
val update1:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 16ul
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h b /\ live h acc /\
disjoint p acc /\ disjoint b acc /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] == S.poly1305_update1
(feval h0 (gsub p 0ul 5ul)).[0] 16 (as_seq h0 b) (feval h0 acc).[0])
let update1 #s pre b acc =
push_frame ();
let e = create (nlimb s) (limb_zero s) in
poly1305_encode_block e b;
fadd_mul_r acc e pre;
pop_frame ()
let poly1305_update1 #s ctx text =
let pre = get_precomp_r ctx in
let acc = get_acc ctx in
update1 pre text acc
inline_for_extraction noextract
val poly1305_update_last:
#s:field_spec
-> p:precomp_r s
-> len:size_t{v len < 16}
-> b:lbuffer uint8 len
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h b /\ live h acc /\
disjoint p acc /\ disjoint b acc /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] == S.poly1305_update1
(feval h0 (gsub p 0ul 5ul)).[0] (v len) (as_seq h0 b) (feval h0 acc).[0])
#push-options "--z3rlimit 200"
let poly1305_update_last #s pre len b acc =
push_frame ();
let e = create (nlimb s) (limb_zero s) in
poly1305_encode_last e len b;
fadd_mul_r acc e pre;
pop_frame ()
#pop-options
inline_for_extraction noextract
val poly1305_update_nblocks:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 (blocklen s)
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h b /\ live h acc /\
disjoint acc p /\ disjoint acc b /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
feval h1 acc ==
Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub p 10ul 5ul)) (as_seq h0 b) (feval h0 acc))
let poly1305_update_nblocks #s pre b acc =
push_frame ();
let e = create (nlimb s) (limb_zero s) in
poly1305_encode_blocks e b;
fmul_rn acc acc pre;
fadd acc acc e;
pop_frame ()
inline_for_extraction noextract
val poly1305_update1_f:
#s:field_spec
-> p:precomp_r s
-> nb:size_t
-> len:size_t{v nb == v len / 16}
-> text:lbuffer uint8 len
-> i:size_t{v i < v nb}
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h text /\ live h acc /\
disjoint acc p /\ disjoint acc text /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
LSeq.repeat_blocks_f #uint8 #S.felem 16
(as_seq h0 text) (S.poly1305_update1 (feval h0 (gsub p 0ul 5ul)).[0] 16) (v nb) (v i) (feval h0 acc).[0])
let poly1305_update1_f #s pre nb len text i acc=
assert ((v i + 1) * 16 <= v nb * 16);
let block = sub #_ #_ #len text (i *! 16ul) 16ul in
update1 #s pre block acc
#push-options "--z3rlimit 100 --max_fuel 1"
inline_for_extraction noextract
val poly1305_update_scalar:
#s:field_spec
-> len:size_t
-> text:lbuffer uint8 len
-> pre:precomp_r s
-> acc:felem s ->
Stack unit
(requires fun h ->
live h text /\ live h acc /\ live h pre /\
disjoint acc text /\ disjoint acc pre /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h pre)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
S.poly1305_update (as_seq h0 text) (feval h0 acc).[0] (feval h0 (gsub pre 0ul 5ul)).[0])
let poly1305_update_scalar #s len text pre acc =
let nb = len /. 16ul in
let rem = len %. 16ul in
let h0 = ST.get () in
LSeq.lemma_repeat_blocks #uint8 #S.felem 16 (as_seq h0 text)
(S.poly1305_update1 (feval h0 (gsub pre 0ul 5ul)).[0] 16)
(S.poly1305_update_last (feval h0 (gsub pre 0ul 5ul)).[0])
(feval h0 acc).[0];
[@ inline_let]
let spec_fh h0 =
LSeq.repeat_blocks_f 16 (as_seq h0 text)
(S.poly1305_update1 (feval h0 (gsub pre 0ul 5ul)).[0] 16) (v nb) in
[@ inline_let]
let inv h (i:nat{i <= v nb}) =
modifies1 acc h0 h /\
live h pre /\ live h text /\ live h acc /\
disjoint acc pre /\ disjoint acc text /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h pre /\
(feval h acc).[0] == Lib.LoopCombinators.repeati i (spec_fh h0) (feval h0 acc).[0] in
Lib.Loops.for (size 0) nb inv
(fun i ->
Lib.LoopCombinators.unfold_repeati (v nb) (spec_fh h0) (feval h0 acc).[0] (v i);
poly1305_update1_f #s pre nb len text i acc);
let h1 = ST.get () in
assert ((feval h1 acc).[0] == Lib.LoopCombinators.repeati (v nb) (spec_fh h0) (feval h0 acc).[0]);
if rem >. 0ul then (
let last = sub text (nb *! 16ul) rem in
as_seq_gsub h1 text (nb *! 16ul) rem;
assert (disjoint acc last);
poly1305_update_last #s pre rem last acc)
#pop-options
inline_for_extraction noextract
val poly1305_update_multi_f:
#s:field_spec
-> p:precomp_r s
-> bs:size_t{v bs == width s * S.size_block}
-> nb:size_t
-> len:size_t{v nb == v len / v bs /\ v len % v bs == 0}
-> text:lbuffer uint8 len
-> i:size_t{v i < v nb}
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h text /\ live h acc /\
disjoint acc p /\ disjoint acc text /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h1 p /\
feval h1 acc ==
LSeq.repeat_blocks_f #uint8 #(Vec.elem (width s))
(v bs) (as_seq h0 text) (Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub p 10ul 5ul))) (v nb) (v i) (feval h0 acc))
let poly1305_update_multi_f #s pre bs nb len text i acc=
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub #_ #_ #len text (i *! bs) bs in
let h1 = ST.get () in
as_seq_gsub h1 text (i *! bs) bs;
poly1305_update_nblocks #s pre block acc
#push-options "--max_fuel 1"
inline_for_extraction noextract
val poly1305_update_multi_loop:
#s:field_spec
-> bs:size_t{v bs == width s * S.size_block}
-> len:size_t{v len % v (blocklen s) == 0}
-> text:lbuffer uint8 len
-> pre:precomp_r s
-> acc:felem s ->
Stack unit
(requires fun h ->
live h pre /\ live h acc /\ live h text /\
disjoint acc text /\ disjoint acc pre /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h pre)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h1 pre /\
feval h1 acc == LSeq.repeat_blocks_multi #uint8 #(Vec.elem (width s)) (v bs) (as_seq h0 text)
(Vec.poly1305_update_nblocks (feval h0 (gsub pre 10ul 5ul))) (feval h0 acc))
let poly1305_update_multi_loop #s bs len text pre acc =
let nb = len /. bs in
let h0 = ST.get () in
LSeq.lemma_repeat_blocks_multi #uint8 #(Vec.elem (width s)) (v bs) (as_seq h0 text)
(Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub pre 10ul 5ul))) (feval h0 acc);
[@ inline_let]
let spec_fh h0 =
LSeq.repeat_blocks_f (v bs) (as_seq h0 text)
(Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub pre 10ul 5ul))) (v nb) in
[@ inline_let]
let inv h (i:nat{i <= v nb}) =
modifies1 acc h0 h /\
live h pre /\ live h text /\ live h acc /\
disjoint acc pre /\ disjoint acc text /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h pre /\
feval h acc == Lib.LoopCombinators.repeati i (spec_fh h0) (feval h0 acc) in
Lib.Loops.for (size 0) nb inv
(fun i ->
Lib.LoopCombinators.unfold_repeati (v nb) (spec_fh h0) (feval h0 acc) (v i);
poly1305_update_multi_f #s pre bs nb len text i acc)
#pop-options
#push-options "--z3rlimit 350"
inline_for_extraction noextract
val poly1305_update_multi:
#s:field_spec
-> len:size_t{0 < v len /\ v len % v (blocklen s) == 0}
-> text:lbuffer uint8 len
-> pre:precomp_r s
-> acc:felem s ->
Stack unit
(requires fun h ->
live h pre /\ live h acc /\ live h text /\
disjoint acc text /\ disjoint acc pre /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h pre)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
Vec.poly1305_update_multi #(width s) (as_seq h0 text)
(feval h0 acc).[0] (feval h0 (gsub pre 0ul 5ul)).[0])
let poly1305_update_multi #s len text pre acc =
let h0 = ST.get () in
assert_norm (v 10ul + v 5ul <= v 20ul);
assert (feval h0 (gsub pre 10ul 5ul) == Vec.compute_rw #(width s) ((feval h0 (gsub pre 0ul 5ul)).[0]));
let bs = blocklen s in
//assert (v bs == width s * S.size_block);
let text0 = sub text 0ul bs in
load_acc #s acc text0;
let len1 = len -! bs in
let text1 = sub text bs len1 in
poly1305_update_multi_loop #s bs len1 text1 pre acc;
fmul_rn_normalize acc pre
#pop-options
inline_for_extraction noextract
val poly1305_update_vec:
#s:field_spec
-> len:size_t
-> text:lbuffer uint8 len
-> pre:precomp_r s
-> acc:felem s ->
Stack unit
(requires fun h ->
live h text /\ live h acc /\ live h pre /\
disjoint acc text /\ disjoint acc pre /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h pre)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
Vec.poly1305_update_vec #(width s) (as_seq h0 text) (feval h0 acc).[0] (feval h0 (gsub pre 0ul 5ul)).[0])
let poly1305_update_vec #s len text pre acc =
let sz_block = blocklen s in
FStar.Math.Lemmas.multiply_fractions (v len) (v sz_block);
let len0 = (len /. sz_block) *! sz_block in
let t0 = sub text 0ul len0 in
FStar.Math.Lemmas.multiple_modulo_lemma (v (len /. sz_block)) (v (blocklen s));
if len0 >. 0ul then poly1305_update_multi len0 t0 pre acc;
let len1 = len -! len0 in
let t1 = sub text len0 len1 in
poly1305_update_scalar #s len1 t1 pre acc
inline_for_extraction noextract | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Hacl.Impl.Poly1305.poly1305_update_st Hacl.Impl.Poly1305.Fields.M32 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.Poly1305.poly1305_ctx",
"Hacl.Impl.Poly1305.Fields.M32",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Hacl.Impl.Poly1305.poly1305_update_scalar",
"Prims.unit",
"Hacl.Impl.Poly1305.Fields.felem",
"Hacl.Impl.Poly1305.get_acc",
"Hacl.Impl.Poly1305.Fields.precomp_r",
"Hacl.Impl.Poly1305.get_precomp_r"
] | [] | false | false | false | true | false | let poly1305_update32 ctx len text =
| let pre = get_precomp_r ctx in
let acc = get_acc ctx in
poly1305_update_scalar #M32 len text pre acc | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.pow_one | val pow_one (k:nat) : Lemma (pow 1 k == 1) | val pow_one (k:nat) : Lemma (pow 1 k == 1) | let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1) | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 24,
"end_line": 22,
"start_col": 0,
"start_line": 20
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Prims.nat -> FStar.Pervasives.Lemma (ensures FStar.Math.Fermat.pow 1 k == 1) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.int",
"FStar.Math.Fermat.pow_one",
"Prims.op_Subtraction",
"Prims.unit"
] | [
"recursion"
] | false | false | true | false | false | let rec pow_one =
| function
| 0 -> ()
| k -> pow_one (k - 1) | false |
CQueue.fst | CQueue.intro_queue_head | val intro_queue_head
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: Ghost.erased (ccell_ptrvalue a))
: SteelGhost unit opened
(vptr (cllist_head x) `star` llist_fragment_head l (cllist_head x) hd `star` vptr (cllist_tail x))
(fun _ -> queue_head x l)
(fun h -> (
let frag = (sel_llist_fragment_head l (cllist_head x) hd) h in
sel (cllist_head x) h == Ghost.reveal hd /\
sel (cllist_tail x) h == fst frag /\
ccell_ptrvalue_is_null (snd frag) == true
))
(fun _ _ _ -> True) | val intro_queue_head
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: Ghost.erased (ccell_ptrvalue a))
: SteelGhost unit opened
(vptr (cllist_head x) `star` llist_fragment_head l (cllist_head x) hd `star` vptr (cllist_tail x))
(fun _ -> queue_head x l)
(fun h -> (
let frag = (sel_llist_fragment_head l (cllist_head x) hd) h in
sel (cllist_head x) h == Ghost.reveal hd /\
sel (cllist_tail x) h == fst frag /\
ccell_ptrvalue_is_null (snd frag) == true
))
(fun _ _ _ -> True) | let intro_queue_head
#_ #a x l hd
=
let ptl = gget (llist_fragment_head l (cllist_head x) hd) in
intro_vrefine
(vptr (cllist_tail x))
(queue_head_refine x l hd ptl);
assert_norm (vptr (cllist_tail x) `vrefine` queue_head_refine x l hd ptl == queue_head_dep1 x l hd ptl);
intro_vdep
(llist_fragment_head l (cllist_head x) hd)
(vptr (cllist_tail x) `vrefine` queue_head_refine x l hd ptl)
(queue_head_dep1 x l hd);
intro_vdep
(vptr (cllist_head x))
(llist_fragment_head l (cllist_head x) hd `vdep` queue_head_dep1 x l hd)
(queue_head_dep2 x l) | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 25,
"end_line": 1225,
"start_col": 0,
"start_line": 1210
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead
unfold
let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a))
val intro_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_tail l phead)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil
l phead
=
intro_vconst phead;
change_equal_slprop
(vconst phead)
(llist_fragment_tail l phead)
val elim_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l phead)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil
l phead
=
change_equal_slprop
(llist_fragment_tail l phead)
(vconst phead);
elim_vconst phead
val intro_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: Ghost.erased (ref (ccell_ptrvalue a)))
(tail: Ghost.erased (ccell_lvalue a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail))
(fun res -> llist_fragment_tail res phead)
(fun h ->
sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\
sel ptail h == Ghost.reveal tail
)
(fun h res h' ->
Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\
sel_llist_fragment_tail res phead h' == ccell_next tail
)
#push-options "--z3rlimit 16"
let intro_llist_fragment_tail_snoc
#_ #a l phead ptail tail
=
let d = gget (vptr (ccell_data tail)) in
let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in
intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l');
intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a);
intro_vdep
(vptr ptail `vrefine` ccell_is_lvalue_refine a)
(vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l')
(llist_fragment_tail_cons_lvalue_payload l');
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead);
intro_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)
(vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l')
(llist_fragment_tail_cons_next_payload l');
intro_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l')
(llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead));
llist_fragment_tail_eq_cons l' phead;
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead))
(llist_fragment_tail l' phead);
let g' = gget (llist_fragment_tail l' phead) in
assert (Ghost.reveal g' == ccell_next tail);
noop ();
l'
#pop-options
[@@erasable]
noeq
type ll_unsnoc_t (a: Type) = {
ll_unsnoc_l: list a;
ll_unsnoc_ptail: ref (ccell_ptrvalue a);
ll_unsnoc_tail: ccell_lvalue a;
}
val elim_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost (ll_unsnoc_t a) opened
(llist_fragment_tail l phead)
(fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail))
(fun _ -> Cons? l)
(fun h res h' ->
Cons? l /\
Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\
sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\
sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\
sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\
sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail)
)
#push-options "--z3rlimit 32"
#restart-solver
let elim_llist_fragment_tail_snoc
#_ #a l phead
=
let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in
llist_fragment_tail_eq_cons l0 phead;
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
elim_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0)
(llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
let ptail = elim_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail_cons_next_payload l0)
in
let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in
change_equal_slprop
(llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail))
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0);
let tail = elim_vdep
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a)
(llist_fragment_tail_cons_lvalue_payload l0)
in
elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a);
let res = {
ll_unsnoc_l = unsnoc_hd l0;
ll_unsnoc_ptail = Ghost.reveal ptail0;
ll_unsnoc_tail = Ghost.reveal tail;
} in
change_equal_slprop
(vptr (Ghost.reveal ptail0))
(vptr res.ll_unsnoc_ptail);
change_equal_slprop
(llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail))
(vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0);
elim_vrefine
(vptr (ccell_data res.ll_unsnoc_tail))
(llist_fragment_tail_cons_data_refine l0);
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail res.ll_unsnoc_l phead);
res
#pop-options
let rec llist_fragment_tail_append
(#opened: _)
(#a: Type)
(phead0: ref (ccell_ptrvalue a))
(l1: Ghost.erased (list a))
(phead1: Ghost.erased (ref (ccell_ptrvalue a)))
(l2: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1)
(fun res -> llist_fragment_tail res phead0)
(fun h ->
Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h
)
(fun h res h' ->
Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
(sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h
)
(decreases (L.length (Ghost.reveal l2)))
=
let g1 = gget (llist_fragment_tail l1 phead0) in
assert (Ghost.reveal phead1 == Ghost.reveal g1);
if Nil? l2
then begin
L.append_l_nil (Ghost.reveal l1);
elim_llist_fragment_tail_nil l2 phead1;
l1
end else begin
let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in
let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in
L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d];
let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in
intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
end
let queue_tail_refine
(#a: Type)
(tail1: ref (ccell_ptrvalue a))
(tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop
= ccell_ptrvalue_is_null tl == true /\ tail1 == tail2
[@@__steel_reduce__]
let queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop
= vptr tail2 `vrefine` queue_tail_refine tail1 tail2
[@@__steel_reduce__]
let queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop
= vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1
[@@__steel_reduce__; __reduce__]
let queue_tail
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
=
llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l
val intro_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun _ -> queue_tail x l)
(fun h ->
sel_llist_fragment_tail l (cllist_head x) h == tail /\
sel (cllist_tail x) h == tail /\
ccell_ptrvalue_is_null (sel tail h)
)
(fun _ _ _ -> True)
let intro_queue_tail
x l tail
=
intro_vrefine (vptr tail) (queue_tail_refine tail tail);
intro_vdep2
(vptr (cllist_tail x))
(vptr tail `vrefine` queue_tail_refine tail tail)
tail
(queue_tail_dep2 x l tail);
intro_vdep2
(llist_fragment_tail l (cllist_head x))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail)
tail
(queue_tail_dep1 x l)
val elim_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(queue_tail x l)
(fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun h -> True)
(fun _ tail h ->
sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\
sel (cllist_tail x) h == Ghost.reveal tail /\
ccell_ptrvalue_is_null (h (vptr tail))
)
let elim_queue_tail
#_ #a x l
=
let tail0 = elim_vdep
(llist_fragment_tail l (cllist_head x))
(queue_tail_dep1 x l)
in
let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in
change_equal_slprop
(queue_tail_dep1 x l (Ghost.reveal tail0))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0);
let tail2 = elim_vdep
(vptr (cllist_tail x))
(queue_tail_dep2 x l tail0)
in
let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in
change_equal_slprop
(queue_tail_dep2 x l tail0 (Ghost.reveal tail2))
(vptr tail3 `vrefine` queue_tail_refine tail0 tail3);
elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3);
change_equal_slprop
(vptr tail3)
(vptr tail);
tail
(* view from the head *)
let llist_fragment_head_data_refine
(#a: Type)
(d: a)
(c: vcell a)
: Tot prop
= c.vcell_data == d
let llist_fragment_head_payload
(#a: Type)
(head: ccell_ptrvalue a)
(d: a)
(llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop))
(x: t_of (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine d)))
: Tot vprop
=
llist_fragment_head (ccell_next (fst x)) (snd x).vcell_next
let rec llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Tot vprop
(decreases (Ghost.reveal l))
=
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
let t_of_llist_fragment_head
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(t_of (llist_fragment_head l phead head) == ref (ccell_ptrvalue a) & ccell_ptrvalue a)
= ()
unfold
let sel_llist_fragment_head
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_head l phead head) /\ True) })
: GTot (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
=
coerce (h (llist_fragment_head l phead head)) (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
val intro_llist_fragment_head_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_head l phead head)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_head l phead head h' == (phead, head))
let intro_llist_fragment_head_nil
l phead head
=
intro_vconst (phead, head);
change_equal_slprop
(vconst (phead, head))
(llist_fragment_head l phead head)
val elim_llist_fragment_head_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_head l phead head h == (phead, head))
let elim_llist_fragment_head_nil
l phead head
=
change_equal_slprop
(llist_fragment_head l phead head)
(vconst (phead, head));
elim_vconst (phead, head)
let llist_fragment_head_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(requires (Cons? (Ghost.reveal l)))
(ensures (
llist_fragment_head l phead head ==
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
))
= assert_norm
(llist_fragment_head l phead head == (
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
))
val intro_llist_fragment_head_cons
(#opened: _)
(#a: Type) (phead: ref (ccell_ptrvalue a)) (head: ccell_lvalue a) (next: (ccell_ptrvalue a)) (tl: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(ccell head `star` llist_fragment_head tl (ccell_next head) next)
(fun res -> llist_fragment_head res phead head)
(fun h -> (h (ccell head)).vcell_next == next)
(fun h res h' ->
Ghost.reveal res == (h (ccell head)).vcell_data :: Ghost.reveal tl /\
h' (llist_fragment_head res phead head) == h (llist_fragment_head tl (ccell_next head) next)
)
let intro_llist_fragment_head_cons
#_ #a phead head next tl
=
let vc = gget (ccell head) in
let l' : (l' : Ghost.erased (list a) { Cons? l' }) = Ghost.hide (vc.vcell_data :: tl) in
intro_ccell_is_lvalue head;
intro_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l'));
intro_vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l')))
(llist_fragment_head tl (ccell_next head) next)
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l')));
llist_fragment_head_eq_cons l' phead head;
change_equal_slprop
(vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l')))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l'))))
(llist_fragment_head l' phead head);
l'
[@@erasable]
noeq
type ll_uncons_t
(a: Type)
= {
ll_uncons_pnext: Ghost.erased (ref (ccell_ptrvalue a));
ll_uncons_next: Ghost.erased (ccell_ptrvalue a);
ll_uncons_tl: Ghost.erased (list a);
}
val elim_llist_fragment_head_cons
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost (ll_uncons_t a) opened
(llist_fragment_head l phead head)
(fun res -> ccell head `star` llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next)
(fun _ -> Cons? (Ghost.reveal l))
(fun h res h' ->
ccell_ptrvalue_is_null head == false /\
Ghost.reveal l == (h' (ccell head)).vcell_data :: Ghost.reveal res.ll_uncons_tl /\
Ghost.reveal res.ll_uncons_pnext == ccell_next head /\
Ghost.reveal res.ll_uncons_next == (h' (ccell head)).vcell_next /\
h' (llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next) == h (llist_fragment_head l phead head)
)
let elim_llist_fragment_head_cons
#_ #a l0 phead head
=
let l : (l : Ghost.erased (list a) { Cons? l }) = l0 in
change_equal_slprop
(llist_fragment_head l0 phead head)
(llist_fragment_head l phead head);
llist_fragment_head_eq_cons l phead head;
change_equal_slprop
(llist_fragment_head l phead head)
(vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l)))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l))));
let x = elim_vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l)))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)))
in
let head2 = gget (ccell_is_lvalue head) in
elim_ccell_is_lvalue head;
elim_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l));
let vhead2 = gget (ccell head) in
let res = {
ll_uncons_pnext = ccell_next head2;
ll_uncons_next = vhead2.vcell_next;
ll_uncons_tl = L.tl l;
} in
change_equal_slprop
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)) (Ghost.reveal x))
(llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next);
res
let rec llist_fragment_head_append
(#opened: _)
(#a: Type)
(l1: Ghost.erased (list a))
(phead1: ref (ccell_ptrvalue a))
(head1: ccell_ptrvalue a)
(l2: Ghost.erased (list a))
(phead2: ref (ccell_ptrvalue a))
(head2: ccell_ptrvalue a)
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_head l1 phead1 head1 `star` llist_fragment_head l2 phead2 head2)
(fun l -> llist_fragment_head l phead1 head1)
(fun h -> sel_llist_fragment_head l1 phead1 head1 h == (Ghost.reveal phead2, Ghost.reveal head2))
(fun h l h' ->
Ghost.reveal l == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
h' (llist_fragment_head l phead1 head1) == h (llist_fragment_head l2 phead2 head2)
)
(decreases (Ghost.reveal l1))
=
if Nil? l1
then begin
elim_llist_fragment_head_nil l1 phead1 head1;
change_equal_slprop
(llist_fragment_head l2 phead2 head2)
(llist_fragment_head l2 phead1 head1);
l2
end else begin
let u = elim_llist_fragment_head_cons l1 phead1 head1 in
let head1' : Ghost.erased (ccell_lvalue a) = head1 in
let l3 = llist_fragment_head_append u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next l2 phead2 head2 in
change_equal_slprop
(llist_fragment_head l3 u.ll_uncons_pnext u.ll_uncons_next)
(llist_fragment_head l3 (ccell_next head1') u.ll_uncons_next);
change_equal_slprop
(ccell head1)
(ccell head1');
let l4 = intro_llist_fragment_head_cons phead1 head1' u.ll_uncons_next l3 in
change_equal_slprop
(llist_fragment_head l4 phead1 head1')
(llist_fragment_head l4 phead1 head1);
l4
end
let rec llist_fragment_head_to_tail
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(vptr phead `star` llist_fragment_head l phead head)
(fun res -> llist_fragment_tail l phead `star` vptr res)
(fun h -> h (vptr phead) == head)
(fun h res h' ->
let v = sel_llist_fragment_head l phead head h in
fst v == Ghost.reveal res /\
fst v == sel_llist_fragment_tail l phead h' /\
snd v == h' (vptr res)
)
(decreases (L.length (Ghost.reveal l)))
=
if Nil? l
then begin
let ptail = Ghost.hide phead in
let gh = gget (vptr phead) in
assert (Ghost.reveal gh == head);
elim_llist_fragment_head_nil l phead head;
intro_llist_fragment_tail_nil l phead;
change_equal_slprop
(vptr phead)
(vptr ptail);
ptail
end else begin
intro_llist_fragment_tail_nil [] phead;
change_equal_slprop
(vptr phead)
(vptr (Ghost.reveal (Ghost.hide phead)));
let uc = elim_llist_fragment_head_cons l phead head in
let head' = elim_ccell_ghost head in
change_equal_slprop
(vptr (ccell_next head'))
(vptr uc.ll_uncons_pnext);
let lc = intro_llist_fragment_tail_snoc [] phead phead head' in
let ptail = llist_fragment_head_to_tail
uc.ll_uncons_tl
uc.ll_uncons_pnext
uc.ll_uncons_next
in
let l' = llist_fragment_tail_append phead lc uc.ll_uncons_pnext uc.ll_uncons_tl in
change_equal_slprop
(llist_fragment_tail l' phead)
(llist_fragment_tail l phead);
ptail
end
#push-options "--z3rlimit 16"
#restart-solver
let rec llist_fragment_tail_to_head
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: ref (ccell_ptrvalue a))
: SteelGhost (Ghost.erased (ccell_ptrvalue a)) opened
(llist_fragment_tail l phead `star` vptr ptail)
(fun head -> vptr phead `star` llist_fragment_head l phead (Ghost.reveal head))
(fun h -> Ghost.reveal ptail == sel_llist_fragment_tail l phead h)
(fun h head h' ->
let v = sel_llist_fragment_head l phead head h' in
fst v == ptail /\
snd v == h (vptr ptail) /\
h' (vptr phead) == Ghost.reveal head
)
(decreases (L.length (Ghost.reveal l)))
=
if Nil? l
then begin
let g = gget (llist_fragment_tail l phead) in
assert (Ghost.reveal g == ptail);
elim_llist_fragment_tail_nil l phead;
change_equal_slprop
(vptr ptail)
(vptr phead);
let head = gget (vptr phead) in
intro_llist_fragment_head_nil l phead head;
head
end else begin
let us = elim_llist_fragment_tail_snoc l phead in
let tail = gget (vptr ptail) in
assert (ccell_next us.ll_unsnoc_tail == ptail);
intro_llist_fragment_head_nil [] (ccell_next us.ll_unsnoc_tail) tail;
change_equal_slprop
(vptr ptail)
(vptr (ccell_next us.ll_unsnoc_tail));
intro_ccell us.ll_unsnoc_tail;
let lc = intro_llist_fragment_head_cons us.ll_unsnoc_ptail us.ll_unsnoc_tail tail [] in
let head = llist_fragment_tail_to_head us.ll_unsnoc_l phead us.ll_unsnoc_ptail in
let g = gget (llist_fragment_head us.ll_unsnoc_l phead head) in
let g : Ghost.erased (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = Ghost.hide (Ghost.reveal g) in
assert (Ghost.reveal g == (Ghost.reveal us.ll_unsnoc_ptail, Ghost.reveal us.ll_unsnoc_tail));
let l' = llist_fragment_head_append us.ll_unsnoc_l phead head lc us.ll_unsnoc_ptail us.ll_unsnoc_tail in
change_equal_slprop
(llist_fragment_head l' phead head)
(llist_fragment_head l phead head);
head
end
#pop-options
val llist_fragment_head_is_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> llist_fragment_head l phead head)
(fun h -> ccell_ptrvalue_is_null (snd (sel_llist_fragment_head l phead head h)) == true)
(fun h _ h' ->
Nil? l == ccell_ptrvalue_is_null head /\
h' (llist_fragment_head l phead head) == h (llist_fragment_head l phead head)
)
let llist_fragment_head_is_nil
l phead head
=
if Nil? l
then begin
elim_llist_fragment_head_nil l phead head;
assert (ccell_ptrvalue_is_null head == true);
intro_llist_fragment_head_nil l phead head
end else begin
let r = elim_llist_fragment_head_cons l phead head in
let head2 : ccell_lvalue _ = head in
change_equal_slprop
(llist_fragment_head r.ll_uncons_tl r.ll_uncons_pnext r.ll_uncons_next)
(llist_fragment_head r.ll_uncons_tl (ccell_next head2) r.ll_uncons_next);
change_equal_slprop
(ccell head)
(ccell head2);
let l' = intro_llist_fragment_head_cons phead head2 r.ll_uncons_next r.ll_uncons_tl in
change_equal_slprop
(llist_fragment_head l' phead head2)
(llist_fragment_head l phead head)
end
val llist_fragment_head_cons_change_phead
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
(phead' : ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> llist_fragment_head l phead' head)
(fun _ -> Cons? l)
(fun h _ h' -> h' (llist_fragment_head l phead' head) == h (llist_fragment_head l phead head))
let llist_fragment_head_cons_change_phead
l phead head phead'
=
let u = elim_llist_fragment_head_cons l phead head in
let head2 : ccell_lvalue _ = head in
change_equal_slprop
(ccell head)
(ccell head2);
change_equal_slprop
(llist_fragment_head u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next)
(llist_fragment_head u.ll_uncons_tl (ccell_next head2) u.ll_uncons_next);
let l' = intro_llist_fragment_head_cons phead' head2 u.ll_uncons_next u.ll_uncons_tl in
change_equal_slprop
(llist_fragment_head l' phead' head2)
(llist_fragment_head l phead' head)
let queue_head_refine
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
(tl: ref (ccell_ptrvalue a))
: Tot prop
= let ptl : (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = ptl in
tl == fst ptl /\ ccell_ptrvalue_is_null (snd ptl) == true
let queue_head_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
: Tot vprop
= vptr (cllist_tail x) `vrefine` queue_head_refine x l hd ptl
let queue_head_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
: Tot vprop
= llist_fragment_head l (cllist_head x) hd `vdep` queue_head_dep1 x l hd
[@@__reduce__]
let queue_head
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
= vptr (cllist_head x) `vdep` queue_head_dep2 x l
val intro_queue_head
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: Ghost.erased (ccell_ptrvalue a))
: SteelGhost unit opened
(vptr (cllist_head x) `star` llist_fragment_head l (cllist_head x) hd `star` vptr (cllist_tail x))
(fun _ -> queue_head x l)
(fun h -> (
let frag = (sel_llist_fragment_head l (cllist_head x) hd) h in
sel (cllist_head x) h == Ghost.reveal hd /\
sel (cllist_tail x) h == fst frag /\
ccell_ptrvalue_is_null (snd frag) == true
))
(fun _ _ _ -> True) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
x: CQueue.t a ->
l: FStar.Ghost.erased (Prims.list a) ->
hd: FStar.Ghost.erased (CQueue.Cell.ccell_ptrvalue a)
-> Steel.Effect.Atomic.SteelGhost Prims.unit | Steel.Effect.Atomic.SteelGhost | [] | [] | [
"Steel.Memory.inames",
"CQueue.t",
"FStar.Ghost.erased",
"Prims.list",
"CQueue.Cell.ccell_ptrvalue",
"Steel.Effect.Atomic.intro_vdep",
"Steel.Reference.vptr",
"CQueue.LList.cllist_head",
"Steel.Effect.Common.vdep",
"CQueue.llist_fragment_head",
"FStar.Ghost.reveal",
"CQueue.queue_head_dep1",
"CQueue.queue_head_dep2",
"Prims.unit",
"Steel.Effect.Common.vrefine",
"Steel.Reference.ref",
"CQueue.LList.cllist_tail",
"CQueue.queue_head_refine",
"Steel.Effect.Common.t_of",
"FStar.Pervasives.assert_norm",
"CQueue.op_Equals_Equals",
"Steel.Effect.Common.vprop",
"Steel.Effect.Atomic.intro_vrefine",
"Steel.Effect.Atomic.gget"
] | [] | false | true | false | false | false | let intro_queue_head #_ #a x l hd =
| let ptl = gget (llist_fragment_head l (cllist_head x) hd) in
intro_vrefine (vptr (cllist_tail x)) (queue_head_refine x l hd ptl);
assert_norm ((vptr (cllist_tail x))
`vrefine`
(queue_head_refine x l hd ptl) ==
queue_head_dep1 x l hd ptl);
intro_vdep (llist_fragment_head l (cllist_head x) hd)
((vptr (cllist_tail x)) `vrefine` (queue_head_refine x l hd ptl))
(queue_head_dep1 x l hd);
intro_vdep (vptr (cllist_head x))
((llist_fragment_head l (cllist_head x) hd) `vdep` (queue_head_dep1 x l hd))
(queue_head_dep2 x l) | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.poly1305_update1 | val poly1305_update1: (#s:field_spec) -> poly1305_update1_st s | val poly1305_update1: (#s:field_spec) -> poly1305_update1_st s | let poly1305_update1 #s ctx text =
let pre = get_precomp_r ctx in
let acc = get_acc ctx in
update1 pre text acc | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 264,
"start_col": 0,
"start_line": 261
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s)
unfold
let op_String_Access #a #len = LSeq.index #a #len
let as_get_acc #s h ctx = (feval h (gsub ctx 0ul (nlimb s))).[0]
let as_get_r #s h ctx = (feval h (gsub ctx (nlimb s) (nlimb s))).[0]
let state_inv_t #s h ctx =
felem_fits h (gsub ctx 0ul (nlimb s)) (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h (gsub ctx (nlimb s) (precomplen s))
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --record_options"
let reveal_ctx_inv' #s ctx ctx' h0 h1 =
let acc_b = gsub ctx 0ul (nlimb s) in
let acc_b' = gsub ctx' 0ul (nlimb s) in
let r_b = gsub ctx (nlimb s) (nlimb s) in
let r_b' = gsub ctx' (nlimb s) (nlimb s) in
let precom_b = gsub ctx (nlimb s) (precomplen s) in
let precom_b' = gsub ctx' (nlimb s) (precomplen s) in
as_seq_gsub h0 ctx 0ul (nlimb s);
as_seq_gsub h1 ctx 0ul (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (nlimb s);
as_seq_gsub h1 ctx (nlimb s) (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (precomplen s);
as_seq_gsub h1 ctx (nlimb s) (precomplen s);
as_seq_gsub h0 ctx' 0ul (nlimb s);
as_seq_gsub h1 ctx' 0ul (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (nlimb s);
as_seq_gsub h1 ctx' (nlimb s) (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (precomplen s);
as_seq_gsub h1 ctx' (nlimb s) (precomplen s);
assert (as_seq h0 acc_b == as_seq h1 acc_b');
assert (as_seq h0 r_b == as_seq h1 r_b');
assert (as_seq h0 precom_b == as_seq h1 precom_b')
val fmul_precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.fmul_precomp_r_pre #(width s) h precomp_b)
let fmul_precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let r_b5 = gsub precomp_b (nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (nlimb s) (nlimb s);
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h r_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h r_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h r_b))
val precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.load_precompute_r_post #(width s) h precomp_b)
#push-options "--z3rlimit 150"
let precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let rn_b = gsub precomp_b (2ul *! nlimb s) (nlimb s) in
let rn_b5 = gsub precomp_b (3ul *! nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (2ul *! nlimb s) (nlimb s);
as_seq_gsub h precomp_b (3ul *! nlimb s) (nlimb s);
fmul_precomp_inv_zeros #s precomp_b h;
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h rn_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h rn_b));
assert (feval h rn_b == Vec.compute_rw (feval h r_b).[0])
#pop-options
let ctx_inv_zeros #s ctx h =
// ctx = [acc_b; r_b; r_b5; rn_b; rn_b5]
let acc_b = gsub ctx 0ul (nlimb s) in
as_seq_gsub h ctx 0ul (nlimb s);
LSeq.eq_intro (feval h acc_b) (LSeq.create (width s) 0);
assert (felem_fits h acc_b (2, 2, 2, 2, 2));
let precomp_b = gsub ctx (nlimb s) (precomplen s) in
LSeq.eq_intro (as_seq h precomp_b) (Lib.Sequence.create (v (precomplen s)) (limb_zero s));
precomp_inv_zeros #s precomp_b h
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
val poly1305_encode_block:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode 16 (as_seq h0 b))
let poly1305_encode_block #s f b =
load_felem_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_blocks:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 (blocklen s) ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
feval h1 f == Vec.load_blocks #(width s) (as_seq h0 b))
let poly1305_encode_blocks #s f b =
load_felems_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_last:
#s:field_spec
-> f:felem s
-> len:size_t{v len < 16}
-> b:lbuffer uint8 len ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode (v len) (as_seq h0 b))
let poly1305_encode_last #s f len b =
push_frame();
let tmp = create 16ul (u8 0) in
update_sub tmp 0ul len b;
let h0 = ST.get () in
Hacl.Impl.Poly1305.Lemmas.nat_from_bytes_le_eq_lemma (v len) (as_seq h0 b);
assert (BSeq.nat_from_bytes_le (as_seq h0 b) == BSeq.nat_from_bytes_le (as_seq h0 tmp));
assert (BSeq.nat_from_bytes_le (as_seq h0 b) < pow2 (v len * 8));
load_felem_le f tmp;
let h1 = ST.get () in
lemma_feval_is_fas_nat h1 f;
set_bit f (len *! 8ul);
pop_frame()
inline_for_extraction noextract
val poly1305_encode_r:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h p /\ disjoint b p)
(ensures fun h0 _ h1 ->
modifies (loc p) h0 h1 /\
F32xN.load_precompute_r_post #(width s) h1 p /\
(feval h1 (gsub p 0ul 5ul)).[0] == S.poly1305_encode_r (as_seq h0 b))
let poly1305_encode_r #s p b =
let lo = uint_from_bytes_le (sub b 0ul 8ul) in
let hi = uint_from_bytes_le (sub b 8ul 8ul) in
let mask0 = u64 0x0ffffffc0fffffff in
let mask1 = u64 0x0ffffffc0ffffffc in
let lo = lo &. mask0 in
let hi = hi &. mask1 in
load_precompute_r p lo hi
[@ Meta.Attribute.specialize ]
let poly1305_init #s ctx key =
let acc = get_acc ctx in
let pre = get_precomp_r ctx in
let kr = sub key 0ul 16ul in
set_zero acc;
poly1305_encode_r #s pre kr
inline_for_extraction noextract
val update1:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 16ul
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h b /\ live h acc /\
disjoint p acc /\ disjoint b acc /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] == S.poly1305_update1
(feval h0 (gsub p 0ul 5ul)).[0] 16 (as_seq h0 b) (feval h0 acc).[0])
let update1 #s pre b acc =
push_frame ();
let e = create (nlimb s) (limb_zero s) in
poly1305_encode_block e b;
fadd_mul_r acc e pre;
pop_frame () | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Hacl.Impl.Poly1305.poly1305_update1_st s | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"Hacl.Impl.Poly1305.poly1305_ctx",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Poly1305.update1",
"Prims.unit",
"Hacl.Impl.Poly1305.Fields.felem",
"Hacl.Impl.Poly1305.get_acc",
"Hacl.Impl.Poly1305.Fields.precomp_r",
"Hacl.Impl.Poly1305.get_precomp_r"
] | [] | false | false | false | false | false | let poly1305_update1 #s ctx text =
| let pre = get_precomp_r ctx in
let acc = get_acc ctx in
update1 pre text acc | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.pow_zero | val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k) | val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k) | let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1) | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 25,
"end_line": 17,
"start_col": 0,
"start_line": 14
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
/// | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Prims.pos -> FStar.Pervasives.Lemma (ensures FStar.Math.Fermat.pow 0 k == 0) (decreases k) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Prims.pos",
"Prims.int",
"FStar.Math.Fermat.pow_zero",
"Prims.op_Subtraction",
"Prims.unit"
] | [
"recursion"
] | false | false | true | false | false | let rec pow_zero k =
| match k with
| 1 -> ()
| _ -> pow_zero (k - 1) | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.poly1305_update1_f | val poly1305_update1_f:
#s:field_spec
-> p:precomp_r s
-> nb:size_t
-> len:size_t{v nb == v len / 16}
-> text:lbuffer uint8 len
-> i:size_t{v i < v nb}
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h text /\ live h acc /\
disjoint acc p /\ disjoint acc text /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
LSeq.repeat_blocks_f #uint8 #S.felem 16
(as_seq h0 text) (S.poly1305_update1 (feval h0 (gsub p 0ul 5ul)).[0] 16) (v nb) (v i) (feval h0 acc).[0]) | val poly1305_update1_f:
#s:field_spec
-> p:precomp_r s
-> nb:size_t
-> len:size_t{v nb == v len / 16}
-> text:lbuffer uint8 len
-> i:size_t{v i < v nb}
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h text /\ live h acc /\
disjoint acc p /\ disjoint acc text /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
LSeq.repeat_blocks_f #uint8 #S.felem 16
(as_seq h0 text) (S.poly1305_update1 (feval h0 (gsub p 0ul 5ul)).[0] 16) (v nb) (v i) (feval h0 acc).[0]) | let poly1305_update1_f #s pre nb len text i acc=
assert ((v i + 1) * 16 <= v nb * 16);
let block = sub #_ #_ #len text (i *! 16ul) 16ul in
update1 #s pre block acc | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 26,
"end_line": 347,
"start_col": 0,
"start_line": 344
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s)
unfold
let op_String_Access #a #len = LSeq.index #a #len
let as_get_acc #s h ctx = (feval h (gsub ctx 0ul (nlimb s))).[0]
let as_get_r #s h ctx = (feval h (gsub ctx (nlimb s) (nlimb s))).[0]
let state_inv_t #s h ctx =
felem_fits h (gsub ctx 0ul (nlimb s)) (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h (gsub ctx (nlimb s) (precomplen s))
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --record_options"
let reveal_ctx_inv' #s ctx ctx' h0 h1 =
let acc_b = gsub ctx 0ul (nlimb s) in
let acc_b' = gsub ctx' 0ul (nlimb s) in
let r_b = gsub ctx (nlimb s) (nlimb s) in
let r_b' = gsub ctx' (nlimb s) (nlimb s) in
let precom_b = gsub ctx (nlimb s) (precomplen s) in
let precom_b' = gsub ctx' (nlimb s) (precomplen s) in
as_seq_gsub h0 ctx 0ul (nlimb s);
as_seq_gsub h1 ctx 0ul (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (nlimb s);
as_seq_gsub h1 ctx (nlimb s) (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (precomplen s);
as_seq_gsub h1 ctx (nlimb s) (precomplen s);
as_seq_gsub h0 ctx' 0ul (nlimb s);
as_seq_gsub h1 ctx' 0ul (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (nlimb s);
as_seq_gsub h1 ctx' (nlimb s) (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (precomplen s);
as_seq_gsub h1 ctx' (nlimb s) (precomplen s);
assert (as_seq h0 acc_b == as_seq h1 acc_b');
assert (as_seq h0 r_b == as_seq h1 r_b');
assert (as_seq h0 precom_b == as_seq h1 precom_b')
val fmul_precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.fmul_precomp_r_pre #(width s) h precomp_b)
let fmul_precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let r_b5 = gsub precomp_b (nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (nlimb s) (nlimb s);
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h r_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h r_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h r_b))
val precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.load_precompute_r_post #(width s) h precomp_b)
#push-options "--z3rlimit 150"
let precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let rn_b = gsub precomp_b (2ul *! nlimb s) (nlimb s) in
let rn_b5 = gsub precomp_b (3ul *! nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (2ul *! nlimb s) (nlimb s);
as_seq_gsub h precomp_b (3ul *! nlimb s) (nlimb s);
fmul_precomp_inv_zeros #s precomp_b h;
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h rn_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h rn_b));
assert (feval h rn_b == Vec.compute_rw (feval h r_b).[0])
#pop-options
let ctx_inv_zeros #s ctx h =
// ctx = [acc_b; r_b; r_b5; rn_b; rn_b5]
let acc_b = gsub ctx 0ul (nlimb s) in
as_seq_gsub h ctx 0ul (nlimb s);
LSeq.eq_intro (feval h acc_b) (LSeq.create (width s) 0);
assert (felem_fits h acc_b (2, 2, 2, 2, 2));
let precomp_b = gsub ctx (nlimb s) (precomplen s) in
LSeq.eq_intro (as_seq h precomp_b) (Lib.Sequence.create (v (precomplen s)) (limb_zero s));
precomp_inv_zeros #s precomp_b h
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
val poly1305_encode_block:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode 16 (as_seq h0 b))
let poly1305_encode_block #s f b =
load_felem_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_blocks:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 (blocklen s) ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
feval h1 f == Vec.load_blocks #(width s) (as_seq h0 b))
let poly1305_encode_blocks #s f b =
load_felems_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_last:
#s:field_spec
-> f:felem s
-> len:size_t{v len < 16}
-> b:lbuffer uint8 len ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode (v len) (as_seq h0 b))
let poly1305_encode_last #s f len b =
push_frame();
let tmp = create 16ul (u8 0) in
update_sub tmp 0ul len b;
let h0 = ST.get () in
Hacl.Impl.Poly1305.Lemmas.nat_from_bytes_le_eq_lemma (v len) (as_seq h0 b);
assert (BSeq.nat_from_bytes_le (as_seq h0 b) == BSeq.nat_from_bytes_le (as_seq h0 tmp));
assert (BSeq.nat_from_bytes_le (as_seq h0 b) < pow2 (v len * 8));
load_felem_le f tmp;
let h1 = ST.get () in
lemma_feval_is_fas_nat h1 f;
set_bit f (len *! 8ul);
pop_frame()
inline_for_extraction noextract
val poly1305_encode_r:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h p /\ disjoint b p)
(ensures fun h0 _ h1 ->
modifies (loc p) h0 h1 /\
F32xN.load_precompute_r_post #(width s) h1 p /\
(feval h1 (gsub p 0ul 5ul)).[0] == S.poly1305_encode_r (as_seq h0 b))
let poly1305_encode_r #s p b =
let lo = uint_from_bytes_le (sub b 0ul 8ul) in
let hi = uint_from_bytes_le (sub b 8ul 8ul) in
let mask0 = u64 0x0ffffffc0fffffff in
let mask1 = u64 0x0ffffffc0ffffffc in
let lo = lo &. mask0 in
let hi = hi &. mask1 in
load_precompute_r p lo hi
[@ Meta.Attribute.specialize ]
let poly1305_init #s ctx key =
let acc = get_acc ctx in
let pre = get_precomp_r ctx in
let kr = sub key 0ul 16ul in
set_zero acc;
poly1305_encode_r #s pre kr
inline_for_extraction noextract
val update1:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 16ul
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h b /\ live h acc /\
disjoint p acc /\ disjoint b acc /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] == S.poly1305_update1
(feval h0 (gsub p 0ul 5ul)).[0] 16 (as_seq h0 b) (feval h0 acc).[0])
let update1 #s pre b acc =
push_frame ();
let e = create (nlimb s) (limb_zero s) in
poly1305_encode_block e b;
fadd_mul_r acc e pre;
pop_frame ()
let poly1305_update1 #s ctx text =
let pre = get_precomp_r ctx in
let acc = get_acc ctx in
update1 pre text acc
inline_for_extraction noextract
val poly1305_update_last:
#s:field_spec
-> p:precomp_r s
-> len:size_t{v len < 16}
-> b:lbuffer uint8 len
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h b /\ live h acc /\
disjoint p acc /\ disjoint b acc /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] == S.poly1305_update1
(feval h0 (gsub p 0ul 5ul)).[0] (v len) (as_seq h0 b) (feval h0 acc).[0])
#push-options "--z3rlimit 200"
let poly1305_update_last #s pre len b acc =
push_frame ();
let e = create (nlimb s) (limb_zero s) in
poly1305_encode_last e len b;
fadd_mul_r acc e pre;
pop_frame ()
#pop-options
inline_for_extraction noextract
val poly1305_update_nblocks:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 (blocklen s)
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h b /\ live h acc /\
disjoint acc p /\ disjoint acc b /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
feval h1 acc ==
Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub p 10ul 5ul)) (as_seq h0 b) (feval h0 acc))
let poly1305_update_nblocks #s pre b acc =
push_frame ();
let e = create (nlimb s) (limb_zero s) in
poly1305_encode_blocks e b;
fmul_rn acc acc pre;
fadd acc acc e;
pop_frame ()
inline_for_extraction noextract
val poly1305_update1_f:
#s:field_spec
-> p:precomp_r s
-> nb:size_t
-> len:size_t{v nb == v len / 16}
-> text:lbuffer uint8 len
-> i:size_t{v i < v nb}
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h text /\ live h acc /\
disjoint acc p /\ disjoint acc text /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
LSeq.repeat_blocks_f #uint8 #S.felem 16
(as_seq h0 text) (S.poly1305_update1 (feval h0 (gsub p 0ul 5ul)).[0] 16) (v nb) (v i) (feval h0 acc).[0]) | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p: Hacl.Impl.Poly1305.Fields.precomp_r s ->
nb: Lib.IntTypes.size_t ->
len: Lib.IntTypes.size_t{Lib.IntTypes.v nb == Lib.IntTypes.v len / 16} ->
text: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len ->
i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v nb} ->
acc: Hacl.Impl.Poly1305.Fields.felem s
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"Hacl.Impl.Poly1305.Fields.precomp_r",
"Lib.IntTypes.size_t",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_Division",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Impl.Poly1305.Fields.felem",
"Hacl.Impl.Poly1305.update1",
"Prims.unit",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Prims._assert",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Prims.op_Addition"
] | [] | false | true | false | false | false | let poly1305_update1_f #s pre nb len text i acc =
| assert ((v i + 1) * 16 <= v nb * 16);
let block = sub #_ #_ #len text (i *! 16ul) 16ul in
update1 #s pre block acc | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.binomial_lt | val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0) | val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0) | let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1) | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 59,
"end_line": 78,
"start_col": 0,
"start_line": 74
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat -> k: Prims.nat{n < k}
-> FStar.Pervasives.Lemma (ensures FStar.Math.Fermat.binomial n k = 0) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Pervasives.Native.Mktuple2",
"Prims.int",
"FStar.Pervasives.Native.tuple2",
"FStar.Math.Fermat.binomial_lt",
"Prims.op_Subtraction",
"Prims.unit"
] | [
"recursion"
] | false | false | true | false | false | let rec binomial_lt n k =
| match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ ->
binomial_lt (n - 1) k;
binomial_lt (n - 1) (k - 1) | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.sum | val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a)) | val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a)) | let rec sum a b f =
if a = b then f a else f a + sum (a + 1) b f | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 46,
"end_line": 145,
"start_col": 0,
"start_line": 144
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n
val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m))
let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
}
val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Prims.nat -> b: Prims.nat{a <= b} -> f: (i: Prims.nat{a <= i /\ i <= b} -> Prims.int)
-> Prims.Tot Prims.int | Prims.Tot | [
"total",
""
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Prims.int",
"Prims.op_Equality",
"Prims.bool",
"Prims.op_Addition",
"FStar.Math.Fermat.sum"
] | [
"recursion"
] | false | false | false | false | false | let rec sum a b f =
| if a = b then f a else f a + sum (a + 1) b f | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.binomial | val binomial (n k:nat) : nat | val binomial (n k:nat) : nat | let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1) | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 57,
"end_line": 68,
"start_col": 0,
"start_line": 64
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
/// | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat -> k: Prims.nat -> Prims.nat | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"Prims.int",
"Prims.op_Addition",
"FStar.Math.Fermat.binomial",
"Prims.op_Subtraction"
] | [
"recursion"
] | false | false | false | true | false | let rec binomial n k =
| match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1) | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.factorial | val factorial: nat -> pos | val factorial: nat -> pos | let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1) | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 30,
"end_line": 93,
"start_col": 0,
"start_line": 91
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.nat -> Prims.pos | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.int",
"FStar.Mul.op_Star",
"FStar.Math.Fermat.factorial",
"Prims.op_Subtraction",
"Prims.pos"
] | [
"recursion"
] | false | false | false | true | false | let rec factorial =
| function
| 0 -> 1
| n -> n * factorial (n - 1) | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.binomial_n | val binomial_n (n:nat) : Lemma (binomial n n == 1) | val binomial_n (n:nat) : Lemma (binomial n n == 1) | let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1) | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 50,
"end_line": 84,
"start_col": 0,
"start_line": 81
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat -> FStar.Pervasives.Lemma (ensures FStar.Math.Fermat.binomial n n == 1) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.int",
"FStar.Math.Fermat.binomial_n",
"Prims.op_Subtraction",
"Prims.unit",
"FStar.Math.Fermat.binomial_lt",
"Prims.op_Addition"
] | [
"recursion"
] | false | false | true | false | false | let rec binomial_n n =
| match n with
| 0 -> ()
| _ ->
binomial_lt n (n + 1);
binomial_n (n - 1) | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.ctx_inv_zeros | val ctx_inv_zeros: #s:field_spec -> ctx:poly1305_ctx s -> h:mem ->
Lemma
(requires as_seq h ctx == Lib.Sequence.create (v (nlimb s +! precomplen s)) (limb_zero s))
(ensures state_inv_t #s h ctx) | val ctx_inv_zeros: #s:field_spec -> ctx:poly1305_ctx s -> h:mem ->
Lemma
(requires as_seq h ctx == Lib.Sequence.create (v (nlimb s +! precomplen s)) (limb_zero s))
(ensures state_inv_t #s h ctx) | let ctx_inv_zeros #s ctx h =
// ctx = [acc_b; r_b; r_b5; rn_b; rn_b5]
let acc_b = gsub ctx 0ul (nlimb s) in
as_seq_gsub h ctx 0ul (nlimb s);
LSeq.eq_intro (feval h acc_b) (LSeq.create (width s) 0);
assert (felem_fits h acc_b (2, 2, 2, 2, 2));
let precomp_b = gsub ctx (nlimb s) (precomplen s) in
LSeq.eq_intro (as_seq h precomp_b) (Lib.Sequence.create (v (precomplen s)) (limb_zero s));
precomp_inv_zeros #s precomp_b h | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 132,
"start_col": 0,
"start_line": 123
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s)
unfold
let op_String_Access #a #len = LSeq.index #a #len
let as_get_acc #s h ctx = (feval h (gsub ctx 0ul (nlimb s))).[0]
let as_get_r #s h ctx = (feval h (gsub ctx (nlimb s) (nlimb s))).[0]
let state_inv_t #s h ctx =
felem_fits h (gsub ctx 0ul (nlimb s)) (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h (gsub ctx (nlimb s) (precomplen s))
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --record_options"
let reveal_ctx_inv' #s ctx ctx' h0 h1 =
let acc_b = gsub ctx 0ul (nlimb s) in
let acc_b' = gsub ctx' 0ul (nlimb s) in
let r_b = gsub ctx (nlimb s) (nlimb s) in
let r_b' = gsub ctx' (nlimb s) (nlimb s) in
let precom_b = gsub ctx (nlimb s) (precomplen s) in
let precom_b' = gsub ctx' (nlimb s) (precomplen s) in
as_seq_gsub h0 ctx 0ul (nlimb s);
as_seq_gsub h1 ctx 0ul (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (nlimb s);
as_seq_gsub h1 ctx (nlimb s) (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (precomplen s);
as_seq_gsub h1 ctx (nlimb s) (precomplen s);
as_seq_gsub h0 ctx' 0ul (nlimb s);
as_seq_gsub h1 ctx' 0ul (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (nlimb s);
as_seq_gsub h1 ctx' (nlimb s) (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (precomplen s);
as_seq_gsub h1 ctx' (nlimb s) (precomplen s);
assert (as_seq h0 acc_b == as_seq h1 acc_b');
assert (as_seq h0 r_b == as_seq h1 r_b');
assert (as_seq h0 precom_b == as_seq h1 precom_b')
val fmul_precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.fmul_precomp_r_pre #(width s) h precomp_b)
let fmul_precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let r_b5 = gsub precomp_b (nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (nlimb s) (nlimb s);
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h r_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h r_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h r_b))
val precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.load_precompute_r_post #(width s) h precomp_b)
#push-options "--z3rlimit 150"
let precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let rn_b = gsub precomp_b (2ul *! nlimb s) (nlimb s) in
let rn_b5 = gsub precomp_b (3ul *! nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (2ul *! nlimb s) (nlimb s);
as_seq_gsub h precomp_b (3ul *! nlimb s) (nlimb s);
fmul_precomp_inv_zeros #s precomp_b h;
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h rn_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h rn_b));
assert (feval h rn_b == Vec.compute_rw (feval h r_b).[0])
#pop-options | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ctx: Hacl.Impl.Poly1305.poly1305_ctx s -> h: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
Lib.Buffer.as_seq h ctx ==
Lib.Sequence.create (Lib.IntTypes.v (Hacl.Impl.Poly1305.Fields.nlimb s +!
Hacl.Impl.Poly1305.Fields.precomplen s))
(Hacl.Impl.Poly1305.Fields.limb_zero s)) (ensures Hacl.Impl.Poly1305.state_inv_t h ctx) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"Hacl.Impl.Poly1305.poly1305_ctx",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Poly1305.precomp_inv_zeros",
"Prims.unit",
"Lib.Sequence.eq_intro",
"Hacl.Impl.Poly1305.Fields.limb",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Poly1305.Fields.precomplen",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.Sequence.create",
"Hacl.Impl.Poly1305.Fields.limb_zero",
"Lib.Buffer.lbuffer_t",
"Hacl.Spec.Poly1305.Field32xN.uint64xN",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.gsub",
"Lib.IntTypes.op_Plus_Bang",
"Hacl.Impl.Poly1305.Fields.nlimb",
"Prims._assert",
"Hacl.Impl.Poly1305.Fields.felem_fits",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Spec.Poly1305.felem",
"Hacl.Impl.Poly1305.Fields.width",
"Hacl.Impl.Poly1305.Fields.feval",
"Lib.Buffer.as_seq_gsub",
"FStar.UInt32.__uint_to_t"
] | [] | true | false | true | false | false | let ctx_inv_zeros #s ctx h =
| let acc_b = gsub ctx 0ul (nlimb s) in
as_seq_gsub h ctx 0ul (nlimb s);
LSeq.eq_intro (feval h acc_b) (LSeq.create (width s) 0);
assert (felem_fits h acc_b (2, 2, 2, 2, 2));
let precomp_b = gsub ctx (nlimb s) (precomplen s) in
LSeq.eq_intro (as_seq h precomp_b) (Lib.Sequence.create (v (precomplen s)) (limb_zero s));
precomp_inv_zeros #s precomp_b h | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.sum_scale | val sum_scale (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (k:int) : Lemma
(ensures k * sum a b f == sum a b (fun i -> k * f i))
(decreases (b - a)) | val sum_scale (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (k:int) : Lemma
(ensures k * sum a b f == sum a b (fun i -> k * f i))
(decreases (b - a)) | let rec sum_scale a b f k =
if a = b then ()
else
begin
sum_scale (a + 1) b f k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k * f i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k * f i)
end | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 7,
"end_line": 190,
"start_col": 0,
"start_line": 182
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n
val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m))
let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
}
val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a))
let rec sum a b f =
if a = b then f a else f a + sum (a + 1) b f
val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g)
(decreases (b - a))
let rec sum_extensionality a b f g =
if a = b then ()
else sum_extensionality (a + 1) b f g
val sum_first (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(sum a b f == f a + sum (a + 1) b f)
let sum_first a b f = ()
val sum_last (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum a (b - 1) f + f b)
(decreases (b - a))
let rec sum_last a b f =
if a + 1 = b then sum_first a b f
else sum_last (a + 1) b f
val sum_const (a:nat) (b:nat{a <= b}) (k:int) : Lemma
(ensures sum a b (fun i -> k) == k * (b - a + 1))
(decreases (b - a))
let rec sum_const a b k =
if a = b then ()
else
begin
sum_const (a + 1) b k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k)
end
val sum_scale (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (k:int) : Lemma
(ensures k * sum a b f == sum a b (fun i -> k * f i)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Prims.nat ->
b: Prims.nat{a <= b} ->
f: (i: Prims.nat{a <= i /\ i <= b} -> Prims.int) ->
k: Prims.int
-> FStar.Pervasives.Lemma
(ensures k * FStar.Math.Fermat.sum a b f == FStar.Math.Fermat.sum a b (fun i -> k * f i))
(decreases b - a) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Prims.int",
"Prims.op_Equality",
"Prims.bool",
"FStar.Math.Fermat.sum_extensionality",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.unit",
"FStar.Math.Fermat.sum_scale"
] | [
"recursion"
] | false | false | true | false | false | let rec sum_scale a b f k =
| if a = b
then ()
else
(sum_scale (a + 1) b f k;
sum_extensionality (a + 1)
b
(fun (i: nat{a <= i /\ i <= b}) -> k * f i)
(fun (i: nat{a + 1 <= i /\ i <= b}) -> k * f i)) | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.sum_const | val sum_const (a:nat) (b:nat{a <= b}) (k:int) : Lemma
(ensures sum a b (fun i -> k) == k * (b - a + 1))
(decreases (b - a)) | val sum_const (a:nat) (b:nat{a <= b}) (k:int) : Lemma
(ensures sum a b (fun i -> k) == k * (b - a + 1))
(decreases (b - a)) | let rec sum_const a b k =
if a = b then ()
else
begin
sum_const (a + 1) b k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k)
end | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 7,
"end_line": 177,
"start_col": 0,
"start_line": 169
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n
val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m))
let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
}
val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a))
let rec sum a b f =
if a = b then f a else f a + sum (a + 1) b f
val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g)
(decreases (b - a))
let rec sum_extensionality a b f g =
if a = b then ()
else sum_extensionality (a + 1) b f g
val sum_first (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(sum a b f == f a + sum (a + 1) b f)
let sum_first a b f = ()
val sum_last (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum a (b - 1) f + f b)
(decreases (b - a))
let rec sum_last a b f =
if a + 1 = b then sum_first a b f
else sum_last (a + 1) b f
val sum_const (a:nat) (b:nat{a <= b}) (k:int) : Lemma
(ensures sum a b (fun i -> k) == k * (b - a + 1)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Prims.nat -> b: Prims.nat{a <= b} -> k: Prims.int
-> FStar.Pervasives.Lemma (ensures FStar.Math.Fermat.sum a b (fun _ -> k) == k * (b - a + 1))
(decreases b - a) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.int",
"Prims.op_Equality",
"Prims.bool",
"FStar.Math.Fermat.sum_extensionality",
"Prims.op_Addition",
"Prims.l_and",
"Prims.unit",
"FStar.Math.Fermat.sum_const"
] | [
"recursion"
] | false | false | true | false | false | let rec sum_const a b k =
| if a = b
then ()
else
(sum_const (a + 1) b k;
sum_extensionality (a + 1)
b
(fun (i: nat{a <= i /\ i <= b}) -> k)
(fun (i: nat{a + 1 <= i /\ i <= b}) -> k)) | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.pow_mod | val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p) | val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p) | let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
} | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 57,
"start_col": 0,
"start_line": 40
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Prims.pos -> a: Prims.int -> k: Prims.nat
-> FStar.Pervasives.Lemma
(ensures FStar.Math.Fermat.pow a k % p == FStar.Math.Fermat.pow (a % p) k % p) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.pos",
"Prims.int",
"Prims.nat",
"Prims.op_Equality",
"Prims.bool",
"FStar.Calc.calc_finish",
"Prims.eq2",
"Prims.op_Modulus",
"FStar.Math.Fermat.pow",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Mul.op_Star",
"Prims.op_Subtraction",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"FStar.Math.Lemmas.lemma_mod_mul_distr_r",
"FStar.Math.Fermat.pow_mod",
"FStar.Math.Lemmas.lemma_mod_mul_distr_l"
] | [
"recursion"
] | false | false | true | false | false | let rec pow_mod p a k =
| if k = 0
then ()
else
calc ( == ) {
pow a k % p;
( == ) { () }
a * pow a (k - 1) % p;
( == ) { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
( == ) { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
( == ) { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
( == ) { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
((a % p) * pow (a % p) (k - 1)) % p;
( == ) { () }
pow (a % p) k % p;
} | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.sum_extensionality | val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g)
(decreases (b - a)) | val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g)
(decreases (b - a)) | let rec sum_extensionality a b f g =
if a = b then ()
else sum_extensionality (a + 1) b f g | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 39,
"end_line": 153,
"start_col": 0,
"start_line": 151
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n
val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m))
let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
}
val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a))
let rec sum a b f =
if a = b then f a else f a + sum (a + 1) b f
val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Prims.nat ->
b: Prims.nat{a <= b} ->
f: (i: Prims.nat{a <= i /\ i <= b} -> Prims.int) ->
g: (i: Prims.nat{a <= i /\ i <= b} -> Prims.int)
-> FStar.Pervasives.Lemma (requires forall (i: Prims.nat{a <= i /\ i <= b}). f i == g i)
(ensures FStar.Math.Fermat.sum a b f == FStar.Math.Fermat.sum a b g)
(decreases b - a) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Prims.int",
"Prims.op_Equality",
"Prims.bool",
"FStar.Math.Fermat.sum_extensionality",
"Prims.op_Addition",
"Prims.unit"
] | [
"recursion"
] | false | false | true | false | false | let rec sum_extensionality a b f g =
| if a = b then () else sum_extensionality (a + 1) b f g | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.sum_last | val sum_last (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum a (b - 1) f + f b)
(decreases (b - a)) | val sum_last (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum a (b - 1) f + f b)
(decreases (b - a)) | let rec sum_last a b f =
if a + 1 = b then sum_first a b f
else sum_last (a + 1) b f | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"end_line": 164,
"start_col": 0,
"start_line": 162
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n
val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m))
let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
}
val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a))
let rec sum a b f =
if a = b then f a else f a + sum (a + 1) b f
val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g)
(decreases (b - a))
let rec sum_extensionality a b f g =
if a = b then ()
else sum_extensionality (a + 1) b f g
val sum_first (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(sum a b f == f a + sum (a + 1) b f)
let sum_first a b f = ()
val sum_last (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum a (b - 1) f + f b) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Prims.nat -> b: Prims.nat{a < b} -> f: (i: Prims.nat{a <= i /\ i <= b} -> Prims.int)
-> FStar.Pervasives.Lemma
(ensures FStar.Math.Fermat.sum a b f == FStar.Math.Fermat.sum a (b - 1) f + f b)
(decreases b - a) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.int",
"Prims.op_Equality",
"Prims.op_Addition",
"FStar.Math.Fermat.sum_first",
"Prims.bool",
"FStar.Math.Fermat.sum_last",
"Prims.unit"
] | [
"recursion"
] | false | false | true | false | false | let rec sum_last a b f =
| if a + 1 = b then sum_first a b f else sum_last (a + 1) b f | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.pow_plus | val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m) | val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m) | let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
} | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 37,
"start_col": 0,
"start_line": 25
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Prims.int -> k: Prims.nat -> m: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
FStar.Math.Fermat.pow a (k + m) == FStar.Math.Fermat.pow a k * FStar.Math.Fermat.pow a m) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.int",
"Prims.nat",
"FStar.Calc.calc_finish",
"Prims.eq2",
"FStar.Math.Fermat.pow",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Prims.op_Subtraction",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"FStar.Math.Fermat.pow_plus"
] | [
"recursion"
] | false | false | true | false | false | let rec pow_plus a k m =
| match k with
| 0 -> ()
| _ ->
calc ( == ) {
pow a (k + m);
( == ) { () }
a * pow a ((k + m) - 1);
( == ) { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
( == ) { () }
pow a k * pow a m;
} | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.sum_add | val sum_add (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f + sum a b g == sum a b (fun i -> f i + g i))
(decreases (b - a)) | val sum_add (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f + sum a b g == sum a b (fun i -> f i + g i))
(decreases (b - a)) | let rec sum_add a b f g =
if a = b then ()
else
begin
sum_add (a + 1) b f g;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> f i + g i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> f i + g i)
end | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 7,
"end_line": 203,
"start_col": 0,
"start_line": 195
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n
val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m))
let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
}
val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a))
let rec sum a b f =
if a = b then f a else f a + sum (a + 1) b f
val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g)
(decreases (b - a))
let rec sum_extensionality a b f g =
if a = b then ()
else sum_extensionality (a + 1) b f g
val sum_first (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(sum a b f == f a + sum (a + 1) b f)
let sum_first a b f = ()
val sum_last (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum a (b - 1) f + f b)
(decreases (b - a))
let rec sum_last a b f =
if a + 1 = b then sum_first a b f
else sum_last (a + 1) b f
val sum_const (a:nat) (b:nat{a <= b}) (k:int) : Lemma
(ensures sum a b (fun i -> k) == k * (b - a + 1))
(decreases (b - a))
let rec sum_const a b k =
if a = b then ()
else
begin
sum_const (a + 1) b k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k)
end
val sum_scale (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (k:int) : Lemma
(ensures k * sum a b f == sum a b (fun i -> k * f i))
(decreases (b - a))
let rec sum_scale a b f k =
if a = b then ()
else
begin
sum_scale (a + 1) b f k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k * f i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k * f i)
end
val sum_add (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f + sum a b g == sum a b (fun i -> f i + g i)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Prims.nat ->
b: Prims.nat{a <= b} ->
f: (i: Prims.nat{a <= i /\ i <= b} -> Prims.int) ->
g: (i: Prims.nat{a <= i /\ i <= b} -> Prims.int)
-> FStar.Pervasives.Lemma
(ensures
FStar.Math.Fermat.sum a b f + FStar.Math.Fermat.sum a b g ==
FStar.Math.Fermat.sum a b (fun i -> f i + g i)) (decreases b - a) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Prims.int",
"Prims.op_Equality",
"Prims.bool",
"FStar.Math.Fermat.sum_extensionality",
"Prims.op_Addition",
"Prims.unit",
"FStar.Math.Fermat.sum_add"
] | [
"recursion"
] | false | false | true | false | false | let rec sum_add a b f g =
| if a = b
then ()
else
(sum_add (a + 1) b f g;
sum_extensionality (a + 1)
b
(fun (i: nat{a <= i /\ i <= b}) -> f i + g i)
(fun (i: nat{a + 1 <= i /\ i <= b}) -> f i + g i)) | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.sum_shift | val sum_shift (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum (a + 1) (b + 1) (fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1)))
(decreases (b - a)) | val sum_shift (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum (a + 1) (b + 1) (fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1)))
(decreases (b - a)) | let rec sum_shift a b f =
if a = b then ()
else
begin
sum_shift (a + 1) b f;
sum_extensionality (a + 2) (b + 1)
(fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1))
(fun (i:nat{a + 1 + 1 <= i /\ i <= b + 1}) -> f (i - 1))
end | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 7,
"end_line": 216,
"start_col": 0,
"start_line": 208
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n
val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m))
let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
}
val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a))
let rec sum a b f =
if a = b then f a else f a + sum (a + 1) b f
val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g)
(decreases (b - a))
let rec sum_extensionality a b f g =
if a = b then ()
else sum_extensionality (a + 1) b f g
val sum_first (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(sum a b f == f a + sum (a + 1) b f)
let sum_first a b f = ()
val sum_last (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum a (b - 1) f + f b)
(decreases (b - a))
let rec sum_last a b f =
if a + 1 = b then sum_first a b f
else sum_last (a + 1) b f
val sum_const (a:nat) (b:nat{a <= b}) (k:int) : Lemma
(ensures sum a b (fun i -> k) == k * (b - a + 1))
(decreases (b - a))
let rec sum_const a b k =
if a = b then ()
else
begin
sum_const (a + 1) b k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k)
end
val sum_scale (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (k:int) : Lemma
(ensures k * sum a b f == sum a b (fun i -> k * f i))
(decreases (b - a))
let rec sum_scale a b f k =
if a = b then ()
else
begin
sum_scale (a + 1) b f k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k * f i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k * f i)
end
val sum_add (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f + sum a b g == sum a b (fun i -> f i + g i))
(decreases (b - a))
let rec sum_add a b f g =
if a = b then ()
else
begin
sum_add (a + 1) b f g;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> f i + g i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> f i + g i)
end
val sum_shift (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum (a + 1) (b + 1) (fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1))) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Prims.nat -> b: Prims.nat{a <= b} -> f: (i: Prims.nat{a <= i /\ i <= b} -> Prims.int)
-> FStar.Pervasives.Lemma
(ensures
FStar.Math.Fermat.sum a b f == FStar.Math.Fermat.sum (a + 1) (b + 1) (fun i -> f (i - 1)))
(decreases b - a) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Prims.int",
"Prims.op_Equality",
"Prims.bool",
"FStar.Math.Fermat.sum_extensionality",
"Prims.op_Addition",
"Prims.op_Subtraction",
"Prims.unit",
"FStar.Math.Fermat.sum_shift"
] | [
"recursion"
] | false | false | true | false | false | let rec sum_shift a b f =
| if a = b
then ()
else
(sum_shift (a + 1) b f;
sum_extensionality (a + 2)
(b + 1)
(fun (i: nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1))
(fun (i: nat{a + 1 + 1 <= i /\ i <= b + 1}) -> f (i - 1))) | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.poly1305_update_multi_f | val poly1305_update_multi_f:
#s:field_spec
-> p:precomp_r s
-> bs:size_t{v bs == width s * S.size_block}
-> nb:size_t
-> len:size_t{v nb == v len / v bs /\ v len % v bs == 0}
-> text:lbuffer uint8 len
-> i:size_t{v i < v nb}
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h text /\ live h acc /\
disjoint acc p /\ disjoint acc text /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h1 p /\
feval h1 acc ==
LSeq.repeat_blocks_f #uint8 #(Vec.elem (width s))
(v bs) (as_seq h0 text) (Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub p 10ul 5ul))) (v nb) (v i) (feval h0 acc)) | val poly1305_update_multi_f:
#s:field_spec
-> p:precomp_r s
-> bs:size_t{v bs == width s * S.size_block}
-> nb:size_t
-> len:size_t{v nb == v len / v bs /\ v len % v bs == 0}
-> text:lbuffer uint8 len
-> i:size_t{v i < v nb}
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h text /\ live h acc /\
disjoint acc p /\ disjoint acc text /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h1 p /\
feval h1 acc ==
LSeq.repeat_blocks_f #uint8 #(Vec.elem (width s))
(v bs) (as_seq h0 text) (Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub p 10ul 5ul))) (v nb) (v i) (feval h0 acc)) | let poly1305_update_multi_f #s pre bs nb len text i acc=
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub #_ #_ #len text (i *! bs) bs in
let h1 = ST.get () in
as_seq_gsub h1 text (i *! bs) bs;
poly1305_update_nblocks #s pre block acc | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 42,
"end_line": 438,
"start_col": 0,
"start_line": 433
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s)
unfold
let op_String_Access #a #len = LSeq.index #a #len
let as_get_acc #s h ctx = (feval h (gsub ctx 0ul (nlimb s))).[0]
let as_get_r #s h ctx = (feval h (gsub ctx (nlimb s) (nlimb s))).[0]
let state_inv_t #s h ctx =
felem_fits h (gsub ctx 0ul (nlimb s)) (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h (gsub ctx (nlimb s) (precomplen s))
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --record_options"
let reveal_ctx_inv' #s ctx ctx' h0 h1 =
let acc_b = gsub ctx 0ul (nlimb s) in
let acc_b' = gsub ctx' 0ul (nlimb s) in
let r_b = gsub ctx (nlimb s) (nlimb s) in
let r_b' = gsub ctx' (nlimb s) (nlimb s) in
let precom_b = gsub ctx (nlimb s) (precomplen s) in
let precom_b' = gsub ctx' (nlimb s) (precomplen s) in
as_seq_gsub h0 ctx 0ul (nlimb s);
as_seq_gsub h1 ctx 0ul (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (nlimb s);
as_seq_gsub h1 ctx (nlimb s) (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (precomplen s);
as_seq_gsub h1 ctx (nlimb s) (precomplen s);
as_seq_gsub h0 ctx' 0ul (nlimb s);
as_seq_gsub h1 ctx' 0ul (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (nlimb s);
as_seq_gsub h1 ctx' (nlimb s) (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (precomplen s);
as_seq_gsub h1 ctx' (nlimb s) (precomplen s);
assert (as_seq h0 acc_b == as_seq h1 acc_b');
assert (as_seq h0 r_b == as_seq h1 r_b');
assert (as_seq h0 precom_b == as_seq h1 precom_b')
val fmul_precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.fmul_precomp_r_pre #(width s) h precomp_b)
let fmul_precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let r_b5 = gsub precomp_b (nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (nlimb s) (nlimb s);
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h r_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h r_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h r_b))
val precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.load_precompute_r_post #(width s) h precomp_b)
#push-options "--z3rlimit 150"
let precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let rn_b = gsub precomp_b (2ul *! nlimb s) (nlimb s) in
let rn_b5 = gsub precomp_b (3ul *! nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (2ul *! nlimb s) (nlimb s);
as_seq_gsub h precomp_b (3ul *! nlimb s) (nlimb s);
fmul_precomp_inv_zeros #s precomp_b h;
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h rn_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h rn_b));
assert (feval h rn_b == Vec.compute_rw (feval h r_b).[0])
#pop-options
let ctx_inv_zeros #s ctx h =
// ctx = [acc_b; r_b; r_b5; rn_b; rn_b5]
let acc_b = gsub ctx 0ul (nlimb s) in
as_seq_gsub h ctx 0ul (nlimb s);
LSeq.eq_intro (feval h acc_b) (LSeq.create (width s) 0);
assert (felem_fits h acc_b (2, 2, 2, 2, 2));
let precomp_b = gsub ctx (nlimb s) (precomplen s) in
LSeq.eq_intro (as_seq h precomp_b) (Lib.Sequence.create (v (precomplen s)) (limb_zero s));
precomp_inv_zeros #s precomp_b h
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
val poly1305_encode_block:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode 16 (as_seq h0 b))
let poly1305_encode_block #s f b =
load_felem_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_blocks:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 (blocklen s) ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
feval h1 f == Vec.load_blocks #(width s) (as_seq h0 b))
let poly1305_encode_blocks #s f b =
load_felems_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_last:
#s:field_spec
-> f:felem s
-> len:size_t{v len < 16}
-> b:lbuffer uint8 len ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode (v len) (as_seq h0 b))
let poly1305_encode_last #s f len b =
push_frame();
let tmp = create 16ul (u8 0) in
update_sub tmp 0ul len b;
let h0 = ST.get () in
Hacl.Impl.Poly1305.Lemmas.nat_from_bytes_le_eq_lemma (v len) (as_seq h0 b);
assert (BSeq.nat_from_bytes_le (as_seq h0 b) == BSeq.nat_from_bytes_le (as_seq h0 tmp));
assert (BSeq.nat_from_bytes_le (as_seq h0 b) < pow2 (v len * 8));
load_felem_le f tmp;
let h1 = ST.get () in
lemma_feval_is_fas_nat h1 f;
set_bit f (len *! 8ul);
pop_frame()
inline_for_extraction noextract
val poly1305_encode_r:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h p /\ disjoint b p)
(ensures fun h0 _ h1 ->
modifies (loc p) h0 h1 /\
F32xN.load_precompute_r_post #(width s) h1 p /\
(feval h1 (gsub p 0ul 5ul)).[0] == S.poly1305_encode_r (as_seq h0 b))
let poly1305_encode_r #s p b =
let lo = uint_from_bytes_le (sub b 0ul 8ul) in
let hi = uint_from_bytes_le (sub b 8ul 8ul) in
let mask0 = u64 0x0ffffffc0fffffff in
let mask1 = u64 0x0ffffffc0ffffffc in
let lo = lo &. mask0 in
let hi = hi &. mask1 in
load_precompute_r p lo hi
[@ Meta.Attribute.specialize ]
let poly1305_init #s ctx key =
let acc = get_acc ctx in
let pre = get_precomp_r ctx in
let kr = sub key 0ul 16ul in
set_zero acc;
poly1305_encode_r #s pre kr
inline_for_extraction noextract
val update1:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 16ul
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h b /\ live h acc /\
disjoint p acc /\ disjoint b acc /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] == S.poly1305_update1
(feval h0 (gsub p 0ul 5ul)).[0] 16 (as_seq h0 b) (feval h0 acc).[0])
let update1 #s pre b acc =
push_frame ();
let e = create (nlimb s) (limb_zero s) in
poly1305_encode_block e b;
fadd_mul_r acc e pre;
pop_frame ()
let poly1305_update1 #s ctx text =
let pre = get_precomp_r ctx in
let acc = get_acc ctx in
update1 pre text acc
inline_for_extraction noextract
val poly1305_update_last:
#s:field_spec
-> p:precomp_r s
-> len:size_t{v len < 16}
-> b:lbuffer uint8 len
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h b /\ live h acc /\
disjoint p acc /\ disjoint b acc /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] == S.poly1305_update1
(feval h0 (gsub p 0ul 5ul)).[0] (v len) (as_seq h0 b) (feval h0 acc).[0])
#push-options "--z3rlimit 200"
let poly1305_update_last #s pre len b acc =
push_frame ();
let e = create (nlimb s) (limb_zero s) in
poly1305_encode_last e len b;
fadd_mul_r acc e pre;
pop_frame ()
#pop-options
inline_for_extraction noextract
val poly1305_update_nblocks:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 (blocklen s)
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h b /\ live h acc /\
disjoint acc p /\ disjoint acc b /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
feval h1 acc ==
Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub p 10ul 5ul)) (as_seq h0 b) (feval h0 acc))
let poly1305_update_nblocks #s pre b acc =
push_frame ();
let e = create (nlimb s) (limb_zero s) in
poly1305_encode_blocks e b;
fmul_rn acc acc pre;
fadd acc acc e;
pop_frame ()
inline_for_extraction noextract
val poly1305_update1_f:
#s:field_spec
-> p:precomp_r s
-> nb:size_t
-> len:size_t{v nb == v len / 16}
-> text:lbuffer uint8 len
-> i:size_t{v i < v nb}
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h text /\ live h acc /\
disjoint acc p /\ disjoint acc text /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
LSeq.repeat_blocks_f #uint8 #S.felem 16
(as_seq h0 text) (S.poly1305_update1 (feval h0 (gsub p 0ul 5ul)).[0] 16) (v nb) (v i) (feval h0 acc).[0])
let poly1305_update1_f #s pre nb len text i acc=
assert ((v i + 1) * 16 <= v nb * 16);
let block = sub #_ #_ #len text (i *! 16ul) 16ul in
update1 #s pre block acc
#push-options "--z3rlimit 100 --max_fuel 1"
inline_for_extraction noextract
val poly1305_update_scalar:
#s:field_spec
-> len:size_t
-> text:lbuffer uint8 len
-> pre:precomp_r s
-> acc:felem s ->
Stack unit
(requires fun h ->
live h text /\ live h acc /\ live h pre /\
disjoint acc text /\ disjoint acc pre /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h pre)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
S.poly1305_update (as_seq h0 text) (feval h0 acc).[0] (feval h0 (gsub pre 0ul 5ul)).[0])
let poly1305_update_scalar #s len text pre acc =
let nb = len /. 16ul in
let rem = len %. 16ul in
let h0 = ST.get () in
LSeq.lemma_repeat_blocks #uint8 #S.felem 16 (as_seq h0 text)
(S.poly1305_update1 (feval h0 (gsub pre 0ul 5ul)).[0] 16)
(S.poly1305_update_last (feval h0 (gsub pre 0ul 5ul)).[0])
(feval h0 acc).[0];
[@ inline_let]
let spec_fh h0 =
LSeq.repeat_blocks_f 16 (as_seq h0 text)
(S.poly1305_update1 (feval h0 (gsub pre 0ul 5ul)).[0] 16) (v nb) in
[@ inline_let]
let inv h (i:nat{i <= v nb}) =
modifies1 acc h0 h /\
live h pre /\ live h text /\ live h acc /\
disjoint acc pre /\ disjoint acc text /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h pre /\
(feval h acc).[0] == Lib.LoopCombinators.repeati i (spec_fh h0) (feval h0 acc).[0] in
Lib.Loops.for (size 0) nb inv
(fun i ->
Lib.LoopCombinators.unfold_repeati (v nb) (spec_fh h0) (feval h0 acc).[0] (v i);
poly1305_update1_f #s pre nb len text i acc);
let h1 = ST.get () in
assert ((feval h1 acc).[0] == Lib.LoopCombinators.repeati (v nb) (spec_fh h0) (feval h0 acc).[0]);
if rem >. 0ul then (
let last = sub text (nb *! 16ul) rem in
as_seq_gsub h1 text (nb *! 16ul) rem;
assert (disjoint acc last);
poly1305_update_last #s pre rem last acc)
#pop-options
inline_for_extraction noextract
val poly1305_update_multi_f:
#s:field_spec
-> p:precomp_r s
-> bs:size_t{v bs == width s * S.size_block}
-> nb:size_t
-> len:size_t{v nb == v len / v bs /\ v len % v bs == 0}
-> text:lbuffer uint8 len
-> i:size_t{v i < v nb}
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h text /\ live h acc /\
disjoint acc p /\ disjoint acc text /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h1 p /\
feval h1 acc ==
LSeq.repeat_blocks_f #uint8 #(Vec.elem (width s))
(v bs) (as_seq h0 text) (Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub p 10ul 5ul))) (v nb) (v i) (feval h0 acc)) | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p: Hacl.Impl.Poly1305.Fields.precomp_r s ->
bs:
Lib.IntTypes.size_t
{Lib.IntTypes.v bs == Hacl.Impl.Poly1305.Fields.width s * Spec.Poly1305.size_block} ->
nb: Lib.IntTypes.size_t ->
len:
Lib.IntTypes.size_t
{ Lib.IntTypes.v nb == Lib.IntTypes.v len / Lib.IntTypes.v bs /\
Lib.IntTypes.v len % Lib.IntTypes.v bs == 0 } ->
text: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len ->
i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v nb} ->
acc: Hacl.Impl.Poly1305.Fields.felem s
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"Hacl.Impl.Poly1305.Fields.precomp_r",
"Lib.IntTypes.size_t",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.Mul.op_Star",
"Hacl.Impl.Poly1305.Fields.width",
"Spec.Poly1305.size_block",
"Prims.l_and",
"Prims.op_Division",
"Prims.op_Modulus",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Impl.Poly1305.Fields.felem",
"Hacl.Impl.Poly1305.poly1305_update_nblocks",
"Prims.unit",
"Lib.Buffer.as_seq_gsub",
"Lib.Buffer.MUT",
"Lib.IntTypes.op_Star_Bang",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.sub",
"Prims._assert",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition"
] | [] | false | true | false | false | false | let poly1305_update_multi_f #s pre bs nb len text i acc =
| assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub #_ #_ #len text (i *! bs) bs in
let h1 = ST.get () in
as_seq_gsub h1 text (i *! bs) bs;
poly1305_update_nblocks #s pre block acc | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.factorial_mod_prime | val factorial_mod_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(requires !k % p = 0)
(ensures False)
(decreases k) | val factorial_mod_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(requires !k % p = 0)
(ensures False)
(decreases k) | let rec factorial_mod_prime p k =
if k = 0 then ()
else
begin
euclid_prime p k !(k - 1);
factorial_mod_prime p (k - 1)
end | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 7,
"end_line": 368,
"start_col": 0,
"start_line": 362
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n
val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m))
let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
}
val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a))
let rec sum a b f =
if a = b then f a else f a + sum (a + 1) b f
val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g)
(decreases (b - a))
let rec sum_extensionality a b f g =
if a = b then ()
else sum_extensionality (a + 1) b f g
val sum_first (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(sum a b f == f a + sum (a + 1) b f)
let sum_first a b f = ()
val sum_last (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum a (b - 1) f + f b)
(decreases (b - a))
let rec sum_last a b f =
if a + 1 = b then sum_first a b f
else sum_last (a + 1) b f
val sum_const (a:nat) (b:nat{a <= b}) (k:int) : Lemma
(ensures sum a b (fun i -> k) == k * (b - a + 1))
(decreases (b - a))
let rec sum_const a b k =
if a = b then ()
else
begin
sum_const (a + 1) b k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k)
end
val sum_scale (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (k:int) : Lemma
(ensures k * sum a b f == sum a b (fun i -> k * f i))
(decreases (b - a))
let rec sum_scale a b f k =
if a = b then ()
else
begin
sum_scale (a + 1) b f k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k * f i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k * f i)
end
val sum_add (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f + sum a b g == sum a b (fun i -> f i + g i))
(decreases (b - a))
let rec sum_add a b f g =
if a = b then ()
else
begin
sum_add (a + 1) b f g;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> f i + g i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> f i + g i)
end
val sum_shift (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum (a + 1) (b + 1) (fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1)))
(decreases (b - a))
let rec sum_shift a b f =
if a = b then ()
else
begin
sum_shift (a + 1) b f;
sum_extensionality (a + 2) (b + 1)
(fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1))
(fun (i:nat{a + 1 + 1 <= i /\ i <= b + 1}) -> f (i - 1))
end
val sum_mod (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (n:pos) : Lemma
(ensures sum a b f % n == sum a b (fun i -> f i % n) % n)
(decreases (b - a))
let rec sum_mod a b f n =
if a = b then ()
else
let g = fun (i:nat{a <= i /\ i <= b}) -> f i % n in
let f' = fun (i:nat{a + 1 <= i /\ i <= b}) -> f i % n in
calc (==) {
sum a b f % n;
== { sum_first a b f }
(f a + sum (a + 1) b f) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b f) n }
(f a + (sum (a + 1) b f) % n) % n;
== { sum_mod (a + 1) b f n; sum_extensionality (a + 1) b f' g }
(f a + sum (a + 1) b g % n) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b g) n }
(f a + sum (a + 1) b g) % n;
== { lemma_mod_plus_distr_l (f a) (sum (a + 1) b g) n }
(f a % n + sum (a + 1) b g) % n;
== { }
sum a b g % n;
}
val binomial_theorem_aux (a b:int) (n:nat) (i:nat{1 <= i /\ i <= n - 1}) : Lemma
(a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)) ==
binomial n i * pow a (n - i) * pow b i)
let binomial_theorem_aux a b n i =
let open FStar.Math.Lemmas in
calc (==) {
a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1));
== { }
a * (binomial (n - 1) i * pow a ((n - i) - 1) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - i) * pow b (i - 1));
== { _ by (FStar.Tactics.CanonCommSemiring.int_semiring()) }
binomial (n - 1) i * ((a * pow a ((n - i) - 1)) * pow b i) +
binomial (n - 1) (i - 1) * (pow a (n - i) * (b * pow b (i - 1)));
== { assert (a * pow a ((n - i) - 1) == pow a (n - i)); assert (b * pow b (i - 1) == pow b i) }
binomial (n - 1) i * (pow a (n - i) * pow b i) +
binomial (n - 1) (i - 1) * (pow a (n - i) * pow b i);
== { _ by (FStar.Tactics.CanonCommSemiring.int_semiring()) }
(binomial (n - 1) i + binomial (n - 1) (i - 1)) * (pow a (n - i) * pow b i);
== { pascal (n - 1) i }
binomial n i * (pow a (n - i) * pow b i);
== { paren_mul_right (binomial n i) (pow a (n - i)) (pow b i) }
binomial n i * pow a (n - i) * pow b i;
}
#push-options "--fuel 2"
val binomial_theorem (a b:int) (n:nat) : Lemma
(pow (a + b) n == sum 0 n (fun i -> binomial n i * pow a (n - i) * pow b i))
let rec binomial_theorem a b n =
if n = 0 then ()
else
if n = 1 then
(binomial_n 1; binomial_0 1)
else
let reorder (a b c d:int) : Lemma (a + b + (c + d) == a + d + (b + c)) =
assert (a + b + (c + d) == a + d + (b + c)) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
pow (a + b) n;
== { }
(a + b) * pow (a + b) (n - 1);
== { distributivity_add_left a b (pow (a + b) (n - 1)) }
a * pow (a + b) (n - 1) + b * pow (a + b) (n - 1);
== { binomial_theorem a b (n - 1) }
a * sum 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * sum 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i);
== { sum_scale 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) a;
sum_scale 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) b
}
sum 0 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
sum 0 (n - 1) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
== { sum_first 0 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_last 0 (n - 1) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun (i:nat{0 <= i /\ i <= n - 1}) -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 0 (n - 2)
(fun (i:nat{0 <= i /\ i <= n - 2}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun (i:nat{0 <= i /\ i <= n - 1}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))}
(a * (binomial (n - 0) 0 * pow a (n - 1 - 0) * pow b 0)) + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) + b * (binomial (n - 1) (n - 1) * pow a (n - 1 - (n - 1)) * pow b (n - 1)));
== { binomial_0 n; binomial_n (n - 1) }
pow a n + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) + pow b n);
== { sum_shift 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> (fun (i:nat{0 <= i /\ i <= n - 2}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) (i - 1))
(fun (i:nat{1 <= i /\ i <= n - 2 + 1}) -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
}
pow a n + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 1 (n - 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))) + pow b n);
== { reorder (pow a n)
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)))
(sum 1 (n - 2 + 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))))
(pow b n)
}
a * pow a (n - 1) + b * pow b (n - 1) +
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
sum 1 (n - 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))));
== { sum_add 1 (n - 1)
(fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
}
pow a n + pow b n +
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))));
== { Classical.forall_intro (binomial_theorem_aux a b n);
sum_extensionality 1 (n - 1)
(fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
(fun i -> binomial n i * pow a (n - i) * pow b i)
}
pow a n + pow b n + sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i);
== { }
pow a n + (sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i) + pow b n);
== { binomial_0 n; binomial_n n }
binomial n 0 * pow a (n - 0) * pow b 0 +
(sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i) +
binomial n n * pow a (n - n) * pow b n);
== { sum_first 0 n (fun i -> binomial n i * pow a (n - i) * pow b i);
sum_last 1 n (fun i -> binomial n i * pow a (n - i) * pow b i);
sum_extensionality 1 n
(fun (i:nat{0 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i)
(fun (i:nat{1 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i);
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> binomial n i * pow a (n - i) * pow b i)
}
sum 0 n (fun i -> binomial n i * pow a (n - i) * pow b i);
}
#pop-options
val factorial_mod_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(requires !k % p = 0)
(ensures False) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Prims.int{FStar.Math.Euclid.is_prime p} -> k: Prims.pos{k < p}
-> FStar.Pervasives.Lemma (requires !k % p = 0) (ensures Prims.l_False) (decreases k) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Prims.int",
"FStar.Math.Euclid.is_prime",
"Prims.pos",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Equality",
"Prims.bool",
"FStar.Math.Fermat.factorial_mod_prime",
"Prims.op_Subtraction",
"Prims.unit",
"FStar.Math.Euclid.euclid_prime",
"FStar.Math.Fermat.op_Bang"
] | [
"recursion"
] | false | false | true | false | false | let rec factorial_mod_prime p k =
| if k = 0
then ()
else
(euclid_prime p k !(k - 1);
factorial_mod_prime p (k - 1)) | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.fmul_precomp_inv_zeros | val fmul_precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.fmul_precomp_r_pre #(width s) h precomp_b) | val fmul_precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.fmul_precomp_r_pre #(width s) h precomp_b) | let fmul_precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let r_b5 = gsub precomp_b (nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (nlimb s) (nlimb s);
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h r_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h r_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h r_b)) | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 84,
"end_line": 96,
"start_col": 0,
"start_line": 87
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s)
unfold
let op_String_Access #a #len = LSeq.index #a #len
let as_get_acc #s h ctx = (feval h (gsub ctx 0ul (nlimb s))).[0]
let as_get_r #s h ctx = (feval h (gsub ctx (nlimb s) (nlimb s))).[0]
let state_inv_t #s h ctx =
felem_fits h (gsub ctx 0ul (nlimb s)) (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h (gsub ctx (nlimb s) (precomplen s))
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --record_options"
let reveal_ctx_inv' #s ctx ctx' h0 h1 =
let acc_b = gsub ctx 0ul (nlimb s) in
let acc_b' = gsub ctx' 0ul (nlimb s) in
let r_b = gsub ctx (nlimb s) (nlimb s) in
let r_b' = gsub ctx' (nlimb s) (nlimb s) in
let precom_b = gsub ctx (nlimb s) (precomplen s) in
let precom_b' = gsub ctx' (nlimb s) (precomplen s) in
as_seq_gsub h0 ctx 0ul (nlimb s);
as_seq_gsub h1 ctx 0ul (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (nlimb s);
as_seq_gsub h1 ctx (nlimb s) (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (precomplen s);
as_seq_gsub h1 ctx (nlimb s) (precomplen s);
as_seq_gsub h0 ctx' 0ul (nlimb s);
as_seq_gsub h1 ctx' 0ul (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (nlimb s);
as_seq_gsub h1 ctx' (nlimb s) (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (precomplen s);
as_seq_gsub h1 ctx' (nlimb s) (precomplen s);
assert (as_seq h0 acc_b == as_seq h1 acc_b');
assert (as_seq h0 r_b == as_seq h1 r_b');
assert (as_seq h0 precom_b == as_seq h1 precom_b')
val fmul_precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.fmul_precomp_r_pre #(width s) h precomp_b) | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
precomp_b:
Lib.Buffer.lbuffer (Hacl.Impl.Poly1305.Fields.limb s) (Hacl.Impl.Poly1305.Fields.precomplen s) ->
h: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
Lib.Buffer.as_seq h precomp_b ==
Lib.Sequence.create (Lib.IntTypes.v (Hacl.Impl.Poly1305.Fields.precomplen s))
(Hacl.Impl.Poly1305.Fields.limb_zero s))
(ensures Hacl.Impl.Poly1305.Field32xN.fmul_precomp_r_pre h precomp_b) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"Lib.Buffer.lbuffer",
"Hacl.Impl.Poly1305.Fields.limb",
"Hacl.Impl.Poly1305.Fields.precomplen",
"FStar.Monotonic.HyperStack.mem",
"Prims._assert",
"Prims.eq2",
"Hacl.Spec.Poly1305.Field32xN.felem5",
"Hacl.Impl.Poly1305.Fields.width",
"Hacl.Impl.Poly1305.Field32xN.as_tup5",
"Hacl.Spec.Poly1305.Field32xN.precomp_r5",
"Prims.unit",
"Lib.Sequence.eq_intro",
"Spec.Poly1305.felem",
"Hacl.Impl.Poly1305.Fields.feval",
"Lib.Sequence.create",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros",
"Lib.Buffer.as_seq_gsub",
"Lib.Buffer.MUT",
"Hacl.Impl.Poly1305.Fields.nlimb",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.lbuffer_t",
"Hacl.Spec.Poly1305.Field32xN.uint64xN",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.gsub"
] | [] | true | false | true | false | false | let fmul_precomp_inv_zeros #s precomp_b h =
| let r_b = gsub precomp_b 0ul (nlimb s) in
let r_b5 = gsub precomp_b (nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (nlimb s) (nlimb s);
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h r_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h r_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h r_b)) | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_code_Vmr | val va_code_Vmr : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_code | val va_code_Vmr : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_code | let va_code_Vmr dst src =
(Ins (S.Vmr dst src)) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 15,
"start_col": 0,
"start_line": 14
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.PPC64LE.Decls.va_operand_vec_opr -> src: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Machine_s.Ins",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.Semantics_s.Vmr",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_Vmr dst src =
| (Ins (S.Vmr dst src)) | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.fermat | val fermat (p:int{is_prime p}) (a:int) : Lemma (pow a p % p == a % p) | val fermat (p:int{is_prime p}) (a:int) : Lemma (pow a p % p == a % p) | let fermat p a =
if a % p = 0 then
begin
small_mod 0 p;
pow_mod p a p;
pow_zero p
end
else
calc (==) {
pow a p % p;
== { pow_mod p a p }
pow (a % p) p % p;
== { fermat_aux p (a % p) }
(a % p) % p;
== { lemma_mod_twice a p }
a % p;
} | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 475,
"start_col": 0,
"start_line": 459
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n
val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m))
let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
}
val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a))
let rec sum a b f =
if a = b then f a else f a + sum (a + 1) b f
val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g)
(decreases (b - a))
let rec sum_extensionality a b f g =
if a = b then ()
else sum_extensionality (a + 1) b f g
val sum_first (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(sum a b f == f a + sum (a + 1) b f)
let sum_first a b f = ()
val sum_last (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum a (b - 1) f + f b)
(decreases (b - a))
let rec sum_last a b f =
if a + 1 = b then sum_first a b f
else sum_last (a + 1) b f
val sum_const (a:nat) (b:nat{a <= b}) (k:int) : Lemma
(ensures sum a b (fun i -> k) == k * (b - a + 1))
(decreases (b - a))
let rec sum_const a b k =
if a = b then ()
else
begin
sum_const (a + 1) b k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k)
end
val sum_scale (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (k:int) : Lemma
(ensures k * sum a b f == sum a b (fun i -> k * f i))
(decreases (b - a))
let rec sum_scale a b f k =
if a = b then ()
else
begin
sum_scale (a + 1) b f k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k * f i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k * f i)
end
val sum_add (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f + sum a b g == sum a b (fun i -> f i + g i))
(decreases (b - a))
let rec sum_add a b f g =
if a = b then ()
else
begin
sum_add (a + 1) b f g;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> f i + g i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> f i + g i)
end
val sum_shift (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum (a + 1) (b + 1) (fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1)))
(decreases (b - a))
let rec sum_shift a b f =
if a = b then ()
else
begin
sum_shift (a + 1) b f;
sum_extensionality (a + 2) (b + 1)
(fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1))
(fun (i:nat{a + 1 + 1 <= i /\ i <= b + 1}) -> f (i - 1))
end
val sum_mod (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (n:pos) : Lemma
(ensures sum a b f % n == sum a b (fun i -> f i % n) % n)
(decreases (b - a))
let rec sum_mod a b f n =
if a = b then ()
else
let g = fun (i:nat{a <= i /\ i <= b}) -> f i % n in
let f' = fun (i:nat{a + 1 <= i /\ i <= b}) -> f i % n in
calc (==) {
sum a b f % n;
== { sum_first a b f }
(f a + sum (a + 1) b f) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b f) n }
(f a + (sum (a + 1) b f) % n) % n;
== { sum_mod (a + 1) b f n; sum_extensionality (a + 1) b f' g }
(f a + sum (a + 1) b g % n) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b g) n }
(f a + sum (a + 1) b g) % n;
== { lemma_mod_plus_distr_l (f a) (sum (a + 1) b g) n }
(f a % n + sum (a + 1) b g) % n;
== { }
sum a b g % n;
}
val binomial_theorem_aux (a b:int) (n:nat) (i:nat{1 <= i /\ i <= n - 1}) : Lemma
(a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)) ==
binomial n i * pow a (n - i) * pow b i)
let binomial_theorem_aux a b n i =
let open FStar.Math.Lemmas in
calc (==) {
a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1));
== { }
a * (binomial (n - 1) i * pow a ((n - i) - 1) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - i) * pow b (i - 1));
== { _ by (FStar.Tactics.CanonCommSemiring.int_semiring()) }
binomial (n - 1) i * ((a * pow a ((n - i) - 1)) * pow b i) +
binomial (n - 1) (i - 1) * (pow a (n - i) * (b * pow b (i - 1)));
== { assert (a * pow a ((n - i) - 1) == pow a (n - i)); assert (b * pow b (i - 1) == pow b i) }
binomial (n - 1) i * (pow a (n - i) * pow b i) +
binomial (n - 1) (i - 1) * (pow a (n - i) * pow b i);
== { _ by (FStar.Tactics.CanonCommSemiring.int_semiring()) }
(binomial (n - 1) i + binomial (n - 1) (i - 1)) * (pow a (n - i) * pow b i);
== { pascal (n - 1) i }
binomial n i * (pow a (n - i) * pow b i);
== { paren_mul_right (binomial n i) (pow a (n - i)) (pow b i) }
binomial n i * pow a (n - i) * pow b i;
}
#push-options "--fuel 2"
val binomial_theorem (a b:int) (n:nat) : Lemma
(pow (a + b) n == sum 0 n (fun i -> binomial n i * pow a (n - i) * pow b i))
let rec binomial_theorem a b n =
if n = 0 then ()
else
if n = 1 then
(binomial_n 1; binomial_0 1)
else
let reorder (a b c d:int) : Lemma (a + b + (c + d) == a + d + (b + c)) =
assert (a + b + (c + d) == a + d + (b + c)) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
pow (a + b) n;
== { }
(a + b) * pow (a + b) (n - 1);
== { distributivity_add_left a b (pow (a + b) (n - 1)) }
a * pow (a + b) (n - 1) + b * pow (a + b) (n - 1);
== { binomial_theorem a b (n - 1) }
a * sum 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * sum 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i);
== { sum_scale 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) a;
sum_scale 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) b
}
sum 0 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
sum 0 (n - 1) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
== { sum_first 0 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_last 0 (n - 1) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun (i:nat{0 <= i /\ i <= n - 1}) -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 0 (n - 2)
(fun (i:nat{0 <= i /\ i <= n - 2}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun (i:nat{0 <= i /\ i <= n - 1}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))}
(a * (binomial (n - 0) 0 * pow a (n - 1 - 0) * pow b 0)) + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) + b * (binomial (n - 1) (n - 1) * pow a (n - 1 - (n - 1)) * pow b (n - 1)));
== { binomial_0 n; binomial_n (n - 1) }
pow a n + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) + pow b n);
== { sum_shift 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> (fun (i:nat{0 <= i /\ i <= n - 2}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) (i - 1))
(fun (i:nat{1 <= i /\ i <= n - 2 + 1}) -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
}
pow a n + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 1 (n - 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))) + pow b n);
== { reorder (pow a n)
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)))
(sum 1 (n - 2 + 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))))
(pow b n)
}
a * pow a (n - 1) + b * pow b (n - 1) +
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
sum 1 (n - 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))));
== { sum_add 1 (n - 1)
(fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
}
pow a n + pow b n +
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))));
== { Classical.forall_intro (binomial_theorem_aux a b n);
sum_extensionality 1 (n - 1)
(fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
(fun i -> binomial n i * pow a (n - i) * pow b i)
}
pow a n + pow b n + sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i);
== { }
pow a n + (sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i) + pow b n);
== { binomial_0 n; binomial_n n }
binomial n 0 * pow a (n - 0) * pow b 0 +
(sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i) +
binomial n n * pow a (n - n) * pow b n);
== { sum_first 0 n (fun i -> binomial n i * pow a (n - i) * pow b i);
sum_last 1 n (fun i -> binomial n i * pow a (n - i) * pow b i);
sum_extensionality 1 n
(fun (i:nat{0 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i)
(fun (i:nat{1 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i);
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> binomial n i * pow a (n - i) * pow b i)
}
sum 0 n (fun i -> binomial n i * pow a (n - i) * pow b i);
}
#pop-options
val factorial_mod_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(requires !k % p = 0)
(ensures False)
(decreases k)
let rec factorial_mod_prime p k =
if k = 0 then ()
else
begin
euclid_prime p k !(k - 1);
factorial_mod_prime p (k - 1)
end
val binomial_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(binomial p k % p == 0)
let binomial_prime p k =
calc (==) {
(p * !(p -1)) % p;
== { FStar.Math.Lemmas.lemma_mod_mul_distr_l p (!(p - 1)) p }
(p % p * !(p - 1)) % p;
== { }
(0 * !(p - 1)) % p;
== { }
0;
};
binomial_factorial (p - k) k;
assert (binomial p k * (!k * !(p - k)) == p * !(p - 1));
euclid_prime p (binomial p k) (!k * !(p - k));
if (binomial p k % p <> 0) then
begin
euclid_prime p !k !(p - k);
assert (!k % p = 0 \/ !(p - k) % p = 0);
if !k % p = 0 then
factorial_mod_prime p k
else
factorial_mod_prime p (p - k)
end
val freshman_aux (p:int{is_prime p}) (a b:int) (i:pos{i < p}): Lemma
((binomial p i * pow a (p - i) * pow b i) % p == 0)
let freshman_aux p a b i =
calc (==) {
(binomial p i * pow a (p - i) * pow b i) % p;
== { paren_mul_right (binomial p i) (pow a (p - i)) (pow b i) }
(binomial p i * (pow a (p - i) * pow b i)) % p;
== { lemma_mod_mul_distr_l (binomial p i) (pow a (p - i) * pow b i) p }
(binomial p i % p * (pow a (p - i) * pow b i)) % p;
== { binomial_prime p i }
0;
}
val freshman (p:int{is_prime p}) (a b:int) : Lemma
(pow (a + b) p % p = (pow a p + pow b p) % p)
let freshman p a b =
let f (i:nat{0 <= i /\ i <= p}) = binomial p i * pow a (p - i) * pow b i % p in
Classical.forall_intro (freshman_aux p a b);
calc (==) {
pow (a + b) p % p;
== { binomial_theorem a b p }
sum 0 p (fun i -> binomial p i * pow a (p - i) * pow b i) % p;
== { sum_mod 0 p (fun i -> binomial p i * pow a (p - i) * pow b i) p }
sum 0 p f % p;
== { sum_first 0 p f; sum_last 1 p f }
(f 0 + sum 1 (p - 1) f + f p) % p;
== { sum_extensionality 1 (p - 1) f (fun _ -> 0) }
(f 0 + sum 1 (p - 1) (fun _ -> 0) + f p) % p;
== { sum_const 1 (p - 1) 0 }
(f 0 + f p) % p;
== { }
((binomial p 0 * pow a p * pow b 0) % p +
(binomial p p * pow a 0 * pow b p) % p) % p;
== { binomial_0 p; binomial_n p; small_mod 1 p }
(pow a p % p + pow b p % p) % p;
== { lemma_mod_plus_distr_l (pow a p) (pow b p % p) p;
lemma_mod_plus_distr_r (pow a p) (pow b p) p }
(pow a p + pow b p) % p;
}
val fermat_aux (p:int{is_prime p}) (a:pos{a < p}) : Lemma
(ensures pow a p % p == a % p)
(decreases a)
let rec fermat_aux p a =
if a = 1 then pow_one p
else
calc (==) {
pow a p % p;
== { }
pow ((a - 1) + 1) p % p;
== { freshman p (a - 1) 1 }
(pow (a - 1) p + pow 1 p) % p;
== { pow_one p }
(pow (a - 1) p + 1) % p;
== { lemma_mod_plus_distr_l (pow (a - 1) p) 1 p }
(pow (a - 1) p % p + 1) % p;
== { fermat_aux p (a - 1) }
((a - 1) % p + 1) % p;
== { lemma_mod_plus_distr_l (a - 1) 1 p }
((a - 1) + 1) % p;
== { }
a % p;
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Prims.int{FStar.Math.Euclid.is_prime p} -> a: Prims.int
-> FStar.Pervasives.Lemma (ensures FStar.Math.Fermat.pow a p % p == a % p) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.int",
"FStar.Math.Euclid.is_prime",
"Prims.op_Equality",
"Prims.op_Modulus",
"FStar.Math.Fermat.pow_zero",
"Prims.unit",
"FStar.Math.Fermat.pow_mod",
"FStar.Math.Lemmas.small_mod",
"Prims.bool",
"FStar.Calc.calc_finish",
"Prims.eq2",
"FStar.Math.Fermat.pow",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"FStar.Math.Fermat.fermat_aux",
"FStar.Math.Lemmas.lemma_mod_twice"
] | [] | false | false | true | false | false | let fermat p a =
| if a % p = 0
then
(small_mod 0 p;
pow_mod p a p;
pow_zero p)
else
calc ( == ) {
pow a p % p;
( == ) { pow_mod p a p }
pow (a % p) p % p;
( == ) { fermat_aux p (a % p) }
(a % p) % p;
( == ) { lemma_mod_twice a p }
a % p;
} | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.mod_mult_congr | val mod_mult_congr (p:int{is_prime p}) (a b c:int) : Lemma
(requires (a * c) % p = (b * c) % p /\ c % p <> 0)
(ensures a % p = b % p) | val mod_mult_congr (p:int{is_prime p}) (a b c:int) : Lemma
(requires (a * c) % p = (b * c) % p /\ c % p <> 0)
(ensures a % p = b % p) | let mod_mult_congr p a b c =
let open FStar.Math.Lemmas in
lemma_mod_mul_distr_l a c p;
lemma_mod_mul_distr_l b c p;
if a % p = b % p then ()
else if b % p < a % p then mod_mult_congr_aux p (a % p) (b % p) c
else mod_mult_congr_aux p (b % p) (a % p) c | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 45,
"end_line": 501,
"start_col": 0,
"start_line": 495
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n
val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m))
let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
}
val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a))
let rec sum a b f =
if a = b then f a else f a + sum (a + 1) b f
val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g)
(decreases (b - a))
let rec sum_extensionality a b f g =
if a = b then ()
else sum_extensionality (a + 1) b f g
val sum_first (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(sum a b f == f a + sum (a + 1) b f)
let sum_first a b f = ()
val sum_last (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum a (b - 1) f + f b)
(decreases (b - a))
let rec sum_last a b f =
if a + 1 = b then sum_first a b f
else sum_last (a + 1) b f
val sum_const (a:nat) (b:nat{a <= b}) (k:int) : Lemma
(ensures sum a b (fun i -> k) == k * (b - a + 1))
(decreases (b - a))
let rec sum_const a b k =
if a = b then ()
else
begin
sum_const (a + 1) b k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k)
end
val sum_scale (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (k:int) : Lemma
(ensures k * sum a b f == sum a b (fun i -> k * f i))
(decreases (b - a))
let rec sum_scale a b f k =
if a = b then ()
else
begin
sum_scale (a + 1) b f k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k * f i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k * f i)
end
val sum_add (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f + sum a b g == sum a b (fun i -> f i + g i))
(decreases (b - a))
let rec sum_add a b f g =
if a = b then ()
else
begin
sum_add (a + 1) b f g;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> f i + g i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> f i + g i)
end
val sum_shift (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum (a + 1) (b + 1) (fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1)))
(decreases (b - a))
let rec sum_shift a b f =
if a = b then ()
else
begin
sum_shift (a + 1) b f;
sum_extensionality (a + 2) (b + 1)
(fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1))
(fun (i:nat{a + 1 + 1 <= i /\ i <= b + 1}) -> f (i - 1))
end
val sum_mod (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (n:pos) : Lemma
(ensures sum a b f % n == sum a b (fun i -> f i % n) % n)
(decreases (b - a))
let rec sum_mod a b f n =
if a = b then ()
else
let g = fun (i:nat{a <= i /\ i <= b}) -> f i % n in
let f' = fun (i:nat{a + 1 <= i /\ i <= b}) -> f i % n in
calc (==) {
sum a b f % n;
== { sum_first a b f }
(f a + sum (a + 1) b f) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b f) n }
(f a + (sum (a + 1) b f) % n) % n;
== { sum_mod (a + 1) b f n; sum_extensionality (a + 1) b f' g }
(f a + sum (a + 1) b g % n) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b g) n }
(f a + sum (a + 1) b g) % n;
== { lemma_mod_plus_distr_l (f a) (sum (a + 1) b g) n }
(f a % n + sum (a + 1) b g) % n;
== { }
sum a b g % n;
}
val binomial_theorem_aux (a b:int) (n:nat) (i:nat{1 <= i /\ i <= n - 1}) : Lemma
(a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)) ==
binomial n i * pow a (n - i) * pow b i)
let binomial_theorem_aux a b n i =
let open FStar.Math.Lemmas in
calc (==) {
a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1));
== { }
a * (binomial (n - 1) i * pow a ((n - i) - 1) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - i) * pow b (i - 1));
== { _ by (FStar.Tactics.CanonCommSemiring.int_semiring()) }
binomial (n - 1) i * ((a * pow a ((n - i) - 1)) * pow b i) +
binomial (n - 1) (i - 1) * (pow a (n - i) * (b * pow b (i - 1)));
== { assert (a * pow a ((n - i) - 1) == pow a (n - i)); assert (b * pow b (i - 1) == pow b i) }
binomial (n - 1) i * (pow a (n - i) * pow b i) +
binomial (n - 1) (i - 1) * (pow a (n - i) * pow b i);
== { _ by (FStar.Tactics.CanonCommSemiring.int_semiring()) }
(binomial (n - 1) i + binomial (n - 1) (i - 1)) * (pow a (n - i) * pow b i);
== { pascal (n - 1) i }
binomial n i * (pow a (n - i) * pow b i);
== { paren_mul_right (binomial n i) (pow a (n - i)) (pow b i) }
binomial n i * pow a (n - i) * pow b i;
}
#push-options "--fuel 2"
val binomial_theorem (a b:int) (n:nat) : Lemma
(pow (a + b) n == sum 0 n (fun i -> binomial n i * pow a (n - i) * pow b i))
let rec binomial_theorem a b n =
if n = 0 then ()
else
if n = 1 then
(binomial_n 1; binomial_0 1)
else
let reorder (a b c d:int) : Lemma (a + b + (c + d) == a + d + (b + c)) =
assert (a + b + (c + d) == a + d + (b + c)) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
pow (a + b) n;
== { }
(a + b) * pow (a + b) (n - 1);
== { distributivity_add_left a b (pow (a + b) (n - 1)) }
a * pow (a + b) (n - 1) + b * pow (a + b) (n - 1);
== { binomial_theorem a b (n - 1) }
a * sum 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * sum 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i);
== { sum_scale 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) a;
sum_scale 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) b
}
sum 0 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
sum 0 (n - 1) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
== { sum_first 0 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_last 0 (n - 1) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun (i:nat{0 <= i /\ i <= n - 1}) -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 0 (n - 2)
(fun (i:nat{0 <= i /\ i <= n - 2}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun (i:nat{0 <= i /\ i <= n - 1}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))}
(a * (binomial (n - 0) 0 * pow a (n - 1 - 0) * pow b 0)) + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) + b * (binomial (n - 1) (n - 1) * pow a (n - 1 - (n - 1)) * pow b (n - 1)));
== { binomial_0 n; binomial_n (n - 1) }
pow a n + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) + pow b n);
== { sum_shift 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> (fun (i:nat{0 <= i /\ i <= n - 2}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) (i - 1))
(fun (i:nat{1 <= i /\ i <= n - 2 + 1}) -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
}
pow a n + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 1 (n - 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))) + pow b n);
== { reorder (pow a n)
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)))
(sum 1 (n - 2 + 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))))
(pow b n)
}
a * pow a (n - 1) + b * pow b (n - 1) +
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
sum 1 (n - 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))));
== { sum_add 1 (n - 1)
(fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
}
pow a n + pow b n +
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))));
== { Classical.forall_intro (binomial_theorem_aux a b n);
sum_extensionality 1 (n - 1)
(fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
(fun i -> binomial n i * pow a (n - i) * pow b i)
}
pow a n + pow b n + sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i);
== { }
pow a n + (sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i) + pow b n);
== { binomial_0 n; binomial_n n }
binomial n 0 * pow a (n - 0) * pow b 0 +
(sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i) +
binomial n n * pow a (n - n) * pow b n);
== { sum_first 0 n (fun i -> binomial n i * pow a (n - i) * pow b i);
sum_last 1 n (fun i -> binomial n i * pow a (n - i) * pow b i);
sum_extensionality 1 n
(fun (i:nat{0 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i)
(fun (i:nat{1 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i);
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> binomial n i * pow a (n - i) * pow b i)
}
sum 0 n (fun i -> binomial n i * pow a (n - i) * pow b i);
}
#pop-options
val factorial_mod_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(requires !k % p = 0)
(ensures False)
(decreases k)
let rec factorial_mod_prime p k =
if k = 0 then ()
else
begin
euclid_prime p k !(k - 1);
factorial_mod_prime p (k - 1)
end
val binomial_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(binomial p k % p == 0)
let binomial_prime p k =
calc (==) {
(p * !(p -1)) % p;
== { FStar.Math.Lemmas.lemma_mod_mul_distr_l p (!(p - 1)) p }
(p % p * !(p - 1)) % p;
== { }
(0 * !(p - 1)) % p;
== { }
0;
};
binomial_factorial (p - k) k;
assert (binomial p k * (!k * !(p - k)) == p * !(p - 1));
euclid_prime p (binomial p k) (!k * !(p - k));
if (binomial p k % p <> 0) then
begin
euclid_prime p !k !(p - k);
assert (!k % p = 0 \/ !(p - k) % p = 0);
if !k % p = 0 then
factorial_mod_prime p k
else
factorial_mod_prime p (p - k)
end
val freshman_aux (p:int{is_prime p}) (a b:int) (i:pos{i < p}): Lemma
((binomial p i * pow a (p - i) * pow b i) % p == 0)
let freshman_aux p a b i =
calc (==) {
(binomial p i * pow a (p - i) * pow b i) % p;
== { paren_mul_right (binomial p i) (pow a (p - i)) (pow b i) }
(binomial p i * (pow a (p - i) * pow b i)) % p;
== { lemma_mod_mul_distr_l (binomial p i) (pow a (p - i) * pow b i) p }
(binomial p i % p * (pow a (p - i) * pow b i)) % p;
== { binomial_prime p i }
0;
}
val freshman (p:int{is_prime p}) (a b:int) : Lemma
(pow (a + b) p % p = (pow a p + pow b p) % p)
let freshman p a b =
let f (i:nat{0 <= i /\ i <= p}) = binomial p i * pow a (p - i) * pow b i % p in
Classical.forall_intro (freshman_aux p a b);
calc (==) {
pow (a + b) p % p;
== { binomial_theorem a b p }
sum 0 p (fun i -> binomial p i * pow a (p - i) * pow b i) % p;
== { sum_mod 0 p (fun i -> binomial p i * pow a (p - i) * pow b i) p }
sum 0 p f % p;
== { sum_first 0 p f; sum_last 1 p f }
(f 0 + sum 1 (p - 1) f + f p) % p;
== { sum_extensionality 1 (p - 1) f (fun _ -> 0) }
(f 0 + sum 1 (p - 1) (fun _ -> 0) + f p) % p;
== { sum_const 1 (p - 1) 0 }
(f 0 + f p) % p;
== { }
((binomial p 0 * pow a p * pow b 0) % p +
(binomial p p * pow a 0 * pow b p) % p) % p;
== { binomial_0 p; binomial_n p; small_mod 1 p }
(pow a p % p + pow b p % p) % p;
== { lemma_mod_plus_distr_l (pow a p) (pow b p % p) p;
lemma_mod_plus_distr_r (pow a p) (pow b p) p }
(pow a p + pow b p) % p;
}
val fermat_aux (p:int{is_prime p}) (a:pos{a < p}) : Lemma
(ensures pow a p % p == a % p)
(decreases a)
let rec fermat_aux p a =
if a = 1 then pow_one p
else
calc (==) {
pow a p % p;
== { }
pow ((a - 1) + 1) p % p;
== { freshman p (a - 1) 1 }
(pow (a - 1) p + pow 1 p) % p;
== { pow_one p }
(pow (a - 1) p + 1) % p;
== { lemma_mod_plus_distr_l (pow (a - 1) p) 1 p }
(pow (a - 1) p % p + 1) % p;
== { fermat_aux p (a - 1) }
((a - 1) % p + 1) % p;
== { lemma_mod_plus_distr_l (a - 1) 1 p }
((a - 1) + 1) % p;
== { }
a % p;
}
let fermat p a =
if a % p = 0 then
begin
small_mod 0 p;
pow_mod p a p;
pow_zero p
end
else
calc (==) {
pow a p % p;
== { pow_mod p a p }
pow (a % p) p % p;
== { fermat_aux p (a % p) }
(a % p) % p;
== { lemma_mod_twice a p }
a % p;
}
val mod_mult_congr_aux (p:int{is_prime p}) (a b c:int) : Lemma
(requires (a * c) % p = (b * c) % p /\ 0 <= b /\ b <= a /\ a < p /\ c % p <> 0)
(ensures a = b)
let mod_mult_congr_aux p a b c =
let open FStar.Math.Lemmas in
calc (==>) {
(a * c) % p == (b * c) % p;
==> { mod_add_both (a * c) (b * c) (-b * c) p }
(a * c - b * c) % p == (b * c - b * c) % p;
==> { swap_mul a c; swap_mul b c; lemma_mul_sub_distr c a b }
(c * (a - b)) % p == (b * c - b * c) % p;
==> { small_mod 0 p; lemma_mod_mul_distr_l c (a - b) p }
(c % p * (a - b)) % p == 0;
};
let r, s = FStar.Math.Euclid.bezout_prime p (c % p) in
FStar.Math.Euclid.euclid p (c % p) (a - b) r s;
small_mod (a - b) p | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Prims.int{FStar.Math.Euclid.is_prime p} -> a: Prims.int -> b: Prims.int -> c: Prims.int
-> FStar.Pervasives.Lemma (requires a * c % p = b * c % p /\ c % p <> 0) (ensures a % p = b % p) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.int",
"FStar.Math.Euclid.is_prime",
"Prims.op_Equality",
"Prims.op_Modulus",
"Prims.bool",
"Prims.op_LessThan",
"FStar.Math.Fermat.mod_mult_congr_aux",
"Prims.unit",
"FStar.Math.Lemmas.lemma_mod_mul_distr_l"
] | [] | false | false | true | false | false | let mod_mult_congr p a b c =
| let open FStar.Math.Lemmas in
lemma_mod_mul_distr_l a c p;
lemma_mod_mul_distr_l b c p;
if a % p = b % p
then ()
else
if b % p < a % p
then mod_mult_congr_aux p (a % p) (b % p) c
else mod_mult_congr_aux p (b % p) (a % p) c | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.sum_mod | val sum_mod (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (n:pos) : Lemma
(ensures sum a b f % n == sum a b (fun i -> f i % n) % n)
(decreases (b - a)) | val sum_mod (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (n:pos) : Lemma
(ensures sum a b f % n == sum a b (fun i -> f i % n) % n)
(decreases (b - a)) | let rec sum_mod a b f n =
if a = b then ()
else
let g = fun (i:nat{a <= i /\ i <= b}) -> f i % n in
let f' = fun (i:nat{a + 1 <= i /\ i <= b}) -> f i % n in
calc (==) {
sum a b f % n;
== { sum_first a b f }
(f a + sum (a + 1) b f) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b f) n }
(f a + (sum (a + 1) b f) % n) % n;
== { sum_mod (a + 1) b f n; sum_extensionality (a + 1) b f' g }
(f a + sum (a + 1) b g % n) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b g) n }
(f a + sum (a + 1) b g) % n;
== { lemma_mod_plus_distr_l (f a) (sum (a + 1) b g) n }
(f a % n + sum (a + 1) b g) % n;
== { }
sum a b g % n;
} | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 240,
"start_col": 0,
"start_line": 221
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n
val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m))
let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
}
val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a))
let rec sum a b f =
if a = b then f a else f a + sum (a + 1) b f
val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g)
(decreases (b - a))
let rec sum_extensionality a b f g =
if a = b then ()
else sum_extensionality (a + 1) b f g
val sum_first (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(sum a b f == f a + sum (a + 1) b f)
let sum_first a b f = ()
val sum_last (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum a (b - 1) f + f b)
(decreases (b - a))
let rec sum_last a b f =
if a + 1 = b then sum_first a b f
else sum_last (a + 1) b f
val sum_const (a:nat) (b:nat{a <= b}) (k:int) : Lemma
(ensures sum a b (fun i -> k) == k * (b - a + 1))
(decreases (b - a))
let rec sum_const a b k =
if a = b then ()
else
begin
sum_const (a + 1) b k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k)
end
val sum_scale (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (k:int) : Lemma
(ensures k * sum a b f == sum a b (fun i -> k * f i))
(decreases (b - a))
let rec sum_scale a b f k =
if a = b then ()
else
begin
sum_scale (a + 1) b f k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k * f i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k * f i)
end
val sum_add (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f + sum a b g == sum a b (fun i -> f i + g i))
(decreases (b - a))
let rec sum_add a b f g =
if a = b then ()
else
begin
sum_add (a + 1) b f g;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> f i + g i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> f i + g i)
end
val sum_shift (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum (a + 1) (b + 1) (fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1)))
(decreases (b - a))
let rec sum_shift a b f =
if a = b then ()
else
begin
sum_shift (a + 1) b f;
sum_extensionality (a + 2) (b + 1)
(fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1))
(fun (i:nat{a + 1 + 1 <= i /\ i <= b + 1}) -> f (i - 1))
end
val sum_mod (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (n:pos) : Lemma
(ensures sum a b f % n == sum a b (fun i -> f i % n) % n) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Prims.nat ->
b: Prims.nat{a <= b} ->
f: (i: Prims.nat{a <= i /\ i <= b} -> Prims.int) ->
n: Prims.pos
-> FStar.Pervasives.Lemma
(ensures FStar.Math.Fermat.sum a b f % n == FStar.Math.Fermat.sum a b (fun i -> f i % n) % n)
(decreases b - a) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Prims.int",
"Prims.pos",
"Prims.op_Equality",
"Prims.bool",
"FStar.Calc.calc_finish",
"Prims.eq2",
"Prims.op_Modulus",
"FStar.Math.Fermat.sum",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Prims.op_Addition",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Fermat.sum_first",
"Prims.squash",
"FStar.Math.Lemmas.lemma_mod_plus_distr_r",
"FStar.Math.Fermat.sum_extensionality",
"FStar.Math.Fermat.sum_mod",
"FStar.Math.Lemmas.lemma_mod_plus_distr_l"
] | [
"recursion"
] | false | false | true | false | false | let rec sum_mod a b f n =
| if a = b
then ()
else
let g = fun (i: nat{a <= i /\ i <= b}) -> f i % n in
let f' = fun (i: nat{a + 1 <= i /\ i <= b}) -> f i % n in
calc ( == ) {
sum a b f % n;
( == ) { sum_first a b f }
(f a + sum (a + 1) b f) % n;
( == ) { lemma_mod_plus_distr_r (f a) (sum (a + 1) b f) n }
(f a + (sum (a + 1) b f) % n) % n;
( == ) { (sum_mod (a + 1) b f n;
sum_extensionality (a + 1) b f' g) }
(f a + sum (a + 1) b g % n) % n;
( == ) { lemma_mod_plus_distr_r (f a) (sum (a + 1) b g) n }
(f a + sum (a + 1) b g) % n;
( == ) { lemma_mod_plus_distr_l (f a) (sum (a + 1) b g) n }
(f a % n + sum (a + 1) b g) % n;
( == ) { () }
sum a b g % n;
} | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_codegen_success_Vmr | val va_codegen_success_Vmr : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_pbool | val va_codegen_success_Vmr : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_pbool | let va_codegen_success_Vmr dst src =
(va_ttrue ()) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 19,
"start_col": 0,
"start_line": 18
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src)) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.PPC64LE.Decls.va_operand_vec_opr -> src: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_Vmr dst src =
| (va_ttrue ()) | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.freshman_aux | val freshman_aux (p:int{is_prime p}) (a b:int) (i:pos{i < p}): Lemma
((binomial p i * pow a (p - i) * pow b i) % p == 0) | val freshman_aux (p:int{is_prime p}) (a b:int) (i:pos{i < p}): Lemma
((binomial p i * pow a (p - i) * pow b i) % p == 0) | let freshman_aux p a b i =
calc (==) {
(binomial p i * pow a (p - i) * pow b i) % p;
== { paren_mul_right (binomial p i) (pow a (p - i)) (pow b i) }
(binomial p i * (pow a (p - i) * pow b i)) % p;
== { lemma_mod_mul_distr_l (binomial p i) (pow a (p - i) * pow b i) p }
(binomial p i % p * (pow a (p - i) * pow b i)) % p;
== { binomial_prime p i }
0;
} | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 3,
"end_line": 406,
"start_col": 0,
"start_line": 397
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n
val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m))
let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
}
val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a))
let rec sum a b f =
if a = b then f a else f a + sum (a + 1) b f
val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g)
(decreases (b - a))
let rec sum_extensionality a b f g =
if a = b then ()
else sum_extensionality (a + 1) b f g
val sum_first (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(sum a b f == f a + sum (a + 1) b f)
let sum_first a b f = ()
val sum_last (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum a (b - 1) f + f b)
(decreases (b - a))
let rec sum_last a b f =
if a + 1 = b then sum_first a b f
else sum_last (a + 1) b f
val sum_const (a:nat) (b:nat{a <= b}) (k:int) : Lemma
(ensures sum a b (fun i -> k) == k * (b - a + 1))
(decreases (b - a))
let rec sum_const a b k =
if a = b then ()
else
begin
sum_const (a + 1) b k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k)
end
val sum_scale (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (k:int) : Lemma
(ensures k * sum a b f == sum a b (fun i -> k * f i))
(decreases (b - a))
let rec sum_scale a b f k =
if a = b then ()
else
begin
sum_scale (a + 1) b f k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k * f i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k * f i)
end
val sum_add (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f + sum a b g == sum a b (fun i -> f i + g i))
(decreases (b - a))
let rec sum_add a b f g =
if a = b then ()
else
begin
sum_add (a + 1) b f g;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> f i + g i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> f i + g i)
end
val sum_shift (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum (a + 1) (b + 1) (fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1)))
(decreases (b - a))
let rec sum_shift a b f =
if a = b then ()
else
begin
sum_shift (a + 1) b f;
sum_extensionality (a + 2) (b + 1)
(fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1))
(fun (i:nat{a + 1 + 1 <= i /\ i <= b + 1}) -> f (i - 1))
end
val sum_mod (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (n:pos) : Lemma
(ensures sum a b f % n == sum a b (fun i -> f i % n) % n)
(decreases (b - a))
let rec sum_mod a b f n =
if a = b then ()
else
let g = fun (i:nat{a <= i /\ i <= b}) -> f i % n in
let f' = fun (i:nat{a + 1 <= i /\ i <= b}) -> f i % n in
calc (==) {
sum a b f % n;
== { sum_first a b f }
(f a + sum (a + 1) b f) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b f) n }
(f a + (sum (a + 1) b f) % n) % n;
== { sum_mod (a + 1) b f n; sum_extensionality (a + 1) b f' g }
(f a + sum (a + 1) b g % n) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b g) n }
(f a + sum (a + 1) b g) % n;
== { lemma_mod_plus_distr_l (f a) (sum (a + 1) b g) n }
(f a % n + sum (a + 1) b g) % n;
== { }
sum a b g % n;
}
val binomial_theorem_aux (a b:int) (n:nat) (i:nat{1 <= i /\ i <= n - 1}) : Lemma
(a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)) ==
binomial n i * pow a (n - i) * pow b i)
let binomial_theorem_aux a b n i =
let open FStar.Math.Lemmas in
calc (==) {
a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1));
== { }
a * (binomial (n - 1) i * pow a ((n - i) - 1) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - i) * pow b (i - 1));
== { _ by (FStar.Tactics.CanonCommSemiring.int_semiring()) }
binomial (n - 1) i * ((a * pow a ((n - i) - 1)) * pow b i) +
binomial (n - 1) (i - 1) * (pow a (n - i) * (b * pow b (i - 1)));
== { assert (a * pow a ((n - i) - 1) == pow a (n - i)); assert (b * pow b (i - 1) == pow b i) }
binomial (n - 1) i * (pow a (n - i) * pow b i) +
binomial (n - 1) (i - 1) * (pow a (n - i) * pow b i);
== { _ by (FStar.Tactics.CanonCommSemiring.int_semiring()) }
(binomial (n - 1) i + binomial (n - 1) (i - 1)) * (pow a (n - i) * pow b i);
== { pascal (n - 1) i }
binomial n i * (pow a (n - i) * pow b i);
== { paren_mul_right (binomial n i) (pow a (n - i)) (pow b i) }
binomial n i * pow a (n - i) * pow b i;
}
#push-options "--fuel 2"
val binomial_theorem (a b:int) (n:nat) : Lemma
(pow (a + b) n == sum 0 n (fun i -> binomial n i * pow a (n - i) * pow b i))
let rec binomial_theorem a b n =
if n = 0 then ()
else
if n = 1 then
(binomial_n 1; binomial_0 1)
else
let reorder (a b c d:int) : Lemma (a + b + (c + d) == a + d + (b + c)) =
assert (a + b + (c + d) == a + d + (b + c)) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
pow (a + b) n;
== { }
(a + b) * pow (a + b) (n - 1);
== { distributivity_add_left a b (pow (a + b) (n - 1)) }
a * pow (a + b) (n - 1) + b * pow (a + b) (n - 1);
== { binomial_theorem a b (n - 1) }
a * sum 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * sum 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i);
== { sum_scale 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) a;
sum_scale 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) b
}
sum 0 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
sum 0 (n - 1) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
== { sum_first 0 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_last 0 (n - 1) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun (i:nat{0 <= i /\ i <= n - 1}) -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 0 (n - 2)
(fun (i:nat{0 <= i /\ i <= n - 2}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun (i:nat{0 <= i /\ i <= n - 1}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))}
(a * (binomial (n - 0) 0 * pow a (n - 1 - 0) * pow b 0)) + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) + b * (binomial (n - 1) (n - 1) * pow a (n - 1 - (n - 1)) * pow b (n - 1)));
== { binomial_0 n; binomial_n (n - 1) }
pow a n + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) + pow b n);
== { sum_shift 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> (fun (i:nat{0 <= i /\ i <= n - 2}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) (i - 1))
(fun (i:nat{1 <= i /\ i <= n - 2 + 1}) -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
}
pow a n + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 1 (n - 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))) + pow b n);
== { reorder (pow a n)
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)))
(sum 1 (n - 2 + 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))))
(pow b n)
}
a * pow a (n - 1) + b * pow b (n - 1) +
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
sum 1 (n - 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))));
== { sum_add 1 (n - 1)
(fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
}
pow a n + pow b n +
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))));
== { Classical.forall_intro (binomial_theorem_aux a b n);
sum_extensionality 1 (n - 1)
(fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
(fun i -> binomial n i * pow a (n - i) * pow b i)
}
pow a n + pow b n + sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i);
== { }
pow a n + (sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i) + pow b n);
== { binomial_0 n; binomial_n n }
binomial n 0 * pow a (n - 0) * pow b 0 +
(sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i) +
binomial n n * pow a (n - n) * pow b n);
== { sum_first 0 n (fun i -> binomial n i * pow a (n - i) * pow b i);
sum_last 1 n (fun i -> binomial n i * pow a (n - i) * pow b i);
sum_extensionality 1 n
(fun (i:nat{0 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i)
(fun (i:nat{1 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i);
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> binomial n i * pow a (n - i) * pow b i)
}
sum 0 n (fun i -> binomial n i * pow a (n - i) * pow b i);
}
#pop-options
val factorial_mod_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(requires !k % p = 0)
(ensures False)
(decreases k)
let rec factorial_mod_prime p k =
if k = 0 then ()
else
begin
euclid_prime p k !(k - 1);
factorial_mod_prime p (k - 1)
end
val binomial_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(binomial p k % p == 0)
let binomial_prime p k =
calc (==) {
(p * !(p -1)) % p;
== { FStar.Math.Lemmas.lemma_mod_mul_distr_l p (!(p - 1)) p }
(p % p * !(p - 1)) % p;
== { }
(0 * !(p - 1)) % p;
== { }
0;
};
binomial_factorial (p - k) k;
assert (binomial p k * (!k * !(p - k)) == p * !(p - 1));
euclid_prime p (binomial p k) (!k * !(p - k));
if (binomial p k % p <> 0) then
begin
euclid_prime p !k !(p - k);
assert (!k % p = 0 \/ !(p - k) % p = 0);
if !k % p = 0 then
factorial_mod_prime p k
else
factorial_mod_prime p (p - k)
end
val freshman_aux (p:int{is_prime p}) (a b:int) (i:pos{i < p}): Lemma | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Prims.int{FStar.Math.Euclid.is_prime p} -> a: Prims.int -> b: Prims.int -> i: Prims.pos{i < p}
-> FStar.Pervasives.Lemma
(ensures
(FStar.Math.Fermat.binomial p i * FStar.Math.Fermat.pow a (p - i)) * FStar.Math.Fermat.pow b i %
p ==
0) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.int",
"FStar.Math.Euclid.is_prime",
"Prims.pos",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Calc.calc_finish",
"Prims.eq2",
"Prims.op_Modulus",
"FStar.Mul.op_Star",
"FStar.Math.Fermat.binomial",
"FStar.Math.Fermat.pow",
"Prims.op_Subtraction",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Lemmas.paren_mul_right",
"Prims.squash",
"FStar.Math.Lemmas.lemma_mod_mul_distr_l",
"FStar.Math.Fermat.binomial_prime"
] | [] | false | false | true | false | false | let freshman_aux p a b i =
| calc ( == ) {
((binomial p i * pow a (p - i)) * pow b i) % p;
( == ) { paren_mul_right (binomial p i) (pow a (p - i)) (pow b i) }
(binomial p i * (pow a (p - i) * pow b i)) % p;
( == ) { lemma_mod_mul_distr_l (binomial p i) (pow a (p - i) * pow b i) p }
((binomial p i % p) * (pow a (p - i) * pow b i)) % p;
( == ) { binomial_prime p i }
0;
} | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.binomial_prime | val binomial_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(binomial p k % p == 0) | val binomial_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(binomial p k % p == 0) | let binomial_prime p k =
calc (==) {
(p * !(p -1)) % p;
== { FStar.Math.Lemmas.lemma_mod_mul_distr_l p (!(p - 1)) p }
(p % p * !(p - 1)) % p;
== { }
(0 * !(p - 1)) % p;
== { }
0;
};
binomial_factorial (p - k) k;
assert (binomial p k * (!k * !(p - k)) == p * !(p - 1));
euclid_prime p (binomial p k) (!k * !(p - k));
if (binomial p k % p <> 0) then
begin
euclid_prime p !k !(p - k);
assert (!k % p = 0 \/ !(p - k) % p = 0);
if !k % p = 0 then
factorial_mod_prime p k
else
factorial_mod_prime p (p - k)
end | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 7,
"end_line": 393,
"start_col": 0,
"start_line": 372
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n
val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m))
let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
}
val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a))
let rec sum a b f =
if a = b then f a else f a + sum (a + 1) b f
val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g)
(decreases (b - a))
let rec sum_extensionality a b f g =
if a = b then ()
else sum_extensionality (a + 1) b f g
val sum_first (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(sum a b f == f a + sum (a + 1) b f)
let sum_first a b f = ()
val sum_last (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum a (b - 1) f + f b)
(decreases (b - a))
let rec sum_last a b f =
if a + 1 = b then sum_first a b f
else sum_last (a + 1) b f
val sum_const (a:nat) (b:nat{a <= b}) (k:int) : Lemma
(ensures sum a b (fun i -> k) == k * (b - a + 1))
(decreases (b - a))
let rec sum_const a b k =
if a = b then ()
else
begin
sum_const (a + 1) b k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k)
end
val sum_scale (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (k:int) : Lemma
(ensures k * sum a b f == sum a b (fun i -> k * f i))
(decreases (b - a))
let rec sum_scale a b f k =
if a = b then ()
else
begin
sum_scale (a + 1) b f k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k * f i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k * f i)
end
val sum_add (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f + sum a b g == sum a b (fun i -> f i + g i))
(decreases (b - a))
let rec sum_add a b f g =
if a = b then ()
else
begin
sum_add (a + 1) b f g;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> f i + g i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> f i + g i)
end
val sum_shift (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum (a + 1) (b + 1) (fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1)))
(decreases (b - a))
let rec sum_shift a b f =
if a = b then ()
else
begin
sum_shift (a + 1) b f;
sum_extensionality (a + 2) (b + 1)
(fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1))
(fun (i:nat{a + 1 + 1 <= i /\ i <= b + 1}) -> f (i - 1))
end
val sum_mod (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (n:pos) : Lemma
(ensures sum a b f % n == sum a b (fun i -> f i % n) % n)
(decreases (b - a))
let rec sum_mod a b f n =
if a = b then ()
else
let g = fun (i:nat{a <= i /\ i <= b}) -> f i % n in
let f' = fun (i:nat{a + 1 <= i /\ i <= b}) -> f i % n in
calc (==) {
sum a b f % n;
== { sum_first a b f }
(f a + sum (a + 1) b f) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b f) n }
(f a + (sum (a + 1) b f) % n) % n;
== { sum_mod (a + 1) b f n; sum_extensionality (a + 1) b f' g }
(f a + sum (a + 1) b g % n) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b g) n }
(f a + sum (a + 1) b g) % n;
== { lemma_mod_plus_distr_l (f a) (sum (a + 1) b g) n }
(f a % n + sum (a + 1) b g) % n;
== { }
sum a b g % n;
}
val binomial_theorem_aux (a b:int) (n:nat) (i:nat{1 <= i /\ i <= n - 1}) : Lemma
(a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)) ==
binomial n i * pow a (n - i) * pow b i)
let binomial_theorem_aux a b n i =
let open FStar.Math.Lemmas in
calc (==) {
a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1));
== { }
a * (binomial (n - 1) i * pow a ((n - i) - 1) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - i) * pow b (i - 1));
== { _ by (FStar.Tactics.CanonCommSemiring.int_semiring()) }
binomial (n - 1) i * ((a * pow a ((n - i) - 1)) * pow b i) +
binomial (n - 1) (i - 1) * (pow a (n - i) * (b * pow b (i - 1)));
== { assert (a * pow a ((n - i) - 1) == pow a (n - i)); assert (b * pow b (i - 1) == pow b i) }
binomial (n - 1) i * (pow a (n - i) * pow b i) +
binomial (n - 1) (i - 1) * (pow a (n - i) * pow b i);
== { _ by (FStar.Tactics.CanonCommSemiring.int_semiring()) }
(binomial (n - 1) i + binomial (n - 1) (i - 1)) * (pow a (n - i) * pow b i);
== { pascal (n - 1) i }
binomial n i * (pow a (n - i) * pow b i);
== { paren_mul_right (binomial n i) (pow a (n - i)) (pow b i) }
binomial n i * pow a (n - i) * pow b i;
}
#push-options "--fuel 2"
val binomial_theorem (a b:int) (n:nat) : Lemma
(pow (a + b) n == sum 0 n (fun i -> binomial n i * pow a (n - i) * pow b i))
let rec binomial_theorem a b n =
if n = 0 then ()
else
if n = 1 then
(binomial_n 1; binomial_0 1)
else
let reorder (a b c d:int) : Lemma (a + b + (c + d) == a + d + (b + c)) =
assert (a + b + (c + d) == a + d + (b + c)) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
pow (a + b) n;
== { }
(a + b) * pow (a + b) (n - 1);
== { distributivity_add_left a b (pow (a + b) (n - 1)) }
a * pow (a + b) (n - 1) + b * pow (a + b) (n - 1);
== { binomial_theorem a b (n - 1) }
a * sum 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * sum 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i);
== { sum_scale 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) a;
sum_scale 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) b
}
sum 0 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
sum 0 (n - 1) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
== { sum_first 0 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_last 0 (n - 1) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun (i:nat{0 <= i /\ i <= n - 1}) -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 0 (n - 2)
(fun (i:nat{0 <= i /\ i <= n - 2}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun (i:nat{0 <= i /\ i <= n - 1}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))}
(a * (binomial (n - 0) 0 * pow a (n - 1 - 0) * pow b 0)) + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) + b * (binomial (n - 1) (n - 1) * pow a (n - 1 - (n - 1)) * pow b (n - 1)));
== { binomial_0 n; binomial_n (n - 1) }
pow a n + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) + pow b n);
== { sum_shift 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> (fun (i:nat{0 <= i /\ i <= n - 2}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) (i - 1))
(fun (i:nat{1 <= i /\ i <= n - 2 + 1}) -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
}
pow a n + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 1 (n - 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))) + pow b n);
== { reorder (pow a n)
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)))
(sum 1 (n - 2 + 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))))
(pow b n)
}
a * pow a (n - 1) + b * pow b (n - 1) +
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
sum 1 (n - 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))));
== { sum_add 1 (n - 1)
(fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
}
pow a n + pow b n +
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))));
== { Classical.forall_intro (binomial_theorem_aux a b n);
sum_extensionality 1 (n - 1)
(fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
(fun i -> binomial n i * pow a (n - i) * pow b i)
}
pow a n + pow b n + sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i);
== { }
pow a n + (sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i) + pow b n);
== { binomial_0 n; binomial_n n }
binomial n 0 * pow a (n - 0) * pow b 0 +
(sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i) +
binomial n n * pow a (n - n) * pow b n);
== { sum_first 0 n (fun i -> binomial n i * pow a (n - i) * pow b i);
sum_last 1 n (fun i -> binomial n i * pow a (n - i) * pow b i);
sum_extensionality 1 n
(fun (i:nat{0 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i)
(fun (i:nat{1 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i);
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> binomial n i * pow a (n - i) * pow b i)
}
sum 0 n (fun i -> binomial n i * pow a (n - i) * pow b i);
}
#pop-options
val factorial_mod_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(requires !k % p = 0)
(ensures False)
(decreases k)
let rec factorial_mod_prime p k =
if k = 0 then ()
else
begin
euclid_prime p k !(k - 1);
factorial_mod_prime p (k - 1)
end
val binomial_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Prims.int{FStar.Math.Euclid.is_prime p} -> k: Prims.pos{k < p}
-> FStar.Pervasives.Lemma (ensures FStar.Math.Fermat.binomial p k % p == 0) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.int",
"FStar.Math.Euclid.is_prime",
"Prims.pos",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_disEquality",
"Prims.op_Modulus",
"FStar.Math.Fermat.binomial",
"Prims.op_Equality",
"FStar.Math.Fermat.op_Bang",
"FStar.Math.Fermat.factorial_mod_prime",
"Prims.bool",
"Prims.op_Subtraction",
"Prims.unit",
"Prims._assert",
"Prims.l_or",
"FStar.Math.Euclid.euclid_prime",
"FStar.Mul.op_Star",
"Prims.eq2",
"FStar.Math.Fermat.binomial_factorial",
"FStar.Calc.calc_finish",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Lemmas.lemma_mod_mul_distr_l",
"Prims.squash"
] | [] | false | false | true | false | false | let binomial_prime p k =
| calc ( == ) {
(p * !(p - 1)) % p;
( == ) { FStar.Math.Lemmas.lemma_mod_mul_distr_l p (!(p - 1)) p }
((p % p) * !(p - 1)) % p;
( == ) { () }
(0 * !(p - 1)) % p;
( == ) { () }
0;
};
binomial_factorial (p - k) k;
assert (binomial p k * (!k * !(p - k)) == p * !(p - 1));
euclid_prime p (binomial p k) (!k * !(p - k));
if (binomial p k % p <> 0)
then
(euclid_prime p !k !(p - k);
assert (!k % p = 0 \/ !(p - k) % p = 0);
if !k % p = 0 then factorial_mod_prime p k else factorial_mod_prime p (p - k)) | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_codegen_success_Mfvsrd | val va_codegen_success_Mfvsrd : dst:va_operand_reg_opr -> src:va_operand_vec_opr -> Tot va_pbool | val va_codegen_success_Mfvsrd : dst:va_operand_reg_opr -> src:va_operand_vec_opr -> Tot va_pbool | let va_codegen_success_Mfvsrd dst src =
(va_ttrue ()) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 48,
"start_col": 0,
"start_line": 47
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src)) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_Mfvsrd dst src =
| (va_ttrue ()) | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.reveal_ctx_inv' | val reveal_ctx_inv': #s:field_spec -> ctx:poly1305_ctx s -> ctx':poly1305_ctx s -> h0:mem -> h1:mem ->
Lemma
(requires Seq.equal (as_seq h0 ctx) (as_seq h1 ctx') /\ state_inv_t h0 ctx)
(ensures
as_get_r h0 ctx == as_get_r h1 ctx' /\
as_get_acc h0 ctx == as_get_acc h1 ctx' /\
state_inv_t h1 ctx') | val reveal_ctx_inv': #s:field_spec -> ctx:poly1305_ctx s -> ctx':poly1305_ctx s -> h0:mem -> h1:mem ->
Lemma
(requires Seq.equal (as_seq h0 ctx) (as_seq h1 ctx') /\ state_inv_t h0 ctx)
(ensures
as_get_r h0 ctx == as_get_r h1 ctx' /\
as_get_acc h0 ctx == as_get_acc h1 ctx' /\
state_inv_t h1 ctx') | let reveal_ctx_inv' #s ctx ctx' h0 h1 =
let acc_b = gsub ctx 0ul (nlimb s) in
let acc_b' = gsub ctx' 0ul (nlimb s) in
let r_b = gsub ctx (nlimb s) (nlimb s) in
let r_b' = gsub ctx' (nlimb s) (nlimb s) in
let precom_b = gsub ctx (nlimb s) (precomplen s) in
let precom_b' = gsub ctx' (nlimb s) (precomplen s) in
as_seq_gsub h0 ctx 0ul (nlimb s);
as_seq_gsub h1 ctx 0ul (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (nlimb s);
as_seq_gsub h1 ctx (nlimb s) (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (precomplen s);
as_seq_gsub h1 ctx (nlimb s) (precomplen s);
as_seq_gsub h0 ctx' 0ul (nlimb s);
as_seq_gsub h1 ctx' 0ul (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (nlimb s);
as_seq_gsub h1 ctx' (nlimb s) (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (precomplen s);
as_seq_gsub h1 ctx' (nlimb s) (precomplen s);
assert (as_seq h0 acc_b == as_seq h1 acc_b');
assert (as_seq h0 r_b == as_seq h1 r_b');
assert (as_seq h0 precom_b == as_seq h1 precom_b') | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 79,
"start_col": 0,
"start_line": 58
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s)
unfold
let op_String_Access #a #len = LSeq.index #a #len
let as_get_acc #s h ctx = (feval h (gsub ctx 0ul (nlimb s))).[0]
let as_get_r #s h ctx = (feval h (gsub ctx (nlimb s) (nlimb s))).[0]
let state_inv_t #s h ctx =
felem_fits h (gsub ctx 0ul (nlimb s)) (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h (gsub ctx (nlimb s) (precomplen s)) | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
ctx: Hacl.Impl.Poly1305.poly1305_ctx s ->
ctx': Hacl.Impl.Poly1305.poly1305_ctx s ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.equal (Lib.Buffer.as_seq h0 ctx) (Lib.Buffer.as_seq h1 ctx') /\
Hacl.Impl.Poly1305.state_inv_t h0 ctx)
(ensures
Hacl.Impl.Poly1305.as_get_r h0 ctx == Hacl.Impl.Poly1305.as_get_r h1 ctx' /\
Hacl.Impl.Poly1305.as_get_acc h0 ctx == Hacl.Impl.Poly1305.as_get_acc h1 ctx' /\
Hacl.Impl.Poly1305.state_inv_t h1 ctx') | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"Hacl.Impl.Poly1305.poly1305_ctx",
"FStar.Monotonic.HyperStack.mem",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.lseq",
"Hacl.Impl.Poly1305.Fields.limb",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Poly1305.Fields.precomplen",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Hacl.Impl.Poly1305.Fields.nlimb",
"Lib.Buffer.as_seq_gsub",
"Lib.IntTypes.op_Plus_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.lbuffer_t",
"Hacl.Spec.Poly1305.Field32xN.uint64xN",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.gsub"
] | [] | true | false | true | false | false | let reveal_ctx_inv' #s ctx ctx' h0 h1 =
| let acc_b = gsub ctx 0ul (nlimb s) in
let acc_b' = gsub ctx' 0ul (nlimb s) in
let r_b = gsub ctx (nlimb s) (nlimb s) in
let r_b' = gsub ctx' (nlimb s) (nlimb s) in
let precom_b = gsub ctx (nlimb s) (precomplen s) in
let precom_b' = gsub ctx' (nlimb s) (precomplen s) in
as_seq_gsub h0 ctx 0ul (nlimb s);
as_seq_gsub h1 ctx 0ul (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (nlimb s);
as_seq_gsub h1 ctx (nlimb s) (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (precomplen s);
as_seq_gsub h1 ctx (nlimb s) (precomplen s);
as_seq_gsub h0 ctx' 0ul (nlimb s);
as_seq_gsub h1 ctx' 0ul (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (nlimb s);
as_seq_gsub h1 ctx' (nlimb s) (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (precomplen s);
as_seq_gsub h1 ctx' (nlimb s) (precomplen s);
assert (as_seq h0 acc_b == as_seq h1 acc_b');
assert (as_seq h0 r_b == as_seq h1 r_b');
assert (as_seq h0 precom_b == as_seq h1 precom_b') | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_code_Mfvsrld | val va_code_Mfvsrld : dst:va_operand_reg_opr -> src:va_operand_vec_opr -> Tot va_code | val va_code_Mfvsrld : dst:va_operand_reg_opr -> src:va_operand_vec_opr -> Tot va_code | let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src)) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 74,
"start_col": 0,
"start_line": 73
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Machine_s.Ins",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.Semantics_s.Mfvsrld",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_Mfvsrld dst src =
| (Ins (S.Mfvsrld dst src)) | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_code_Mfvsrd | val va_code_Mfvsrd : dst:va_operand_reg_opr -> src:va_operand_vec_opr -> Tot va_code | val va_code_Mfvsrd : dst:va_operand_reg_opr -> src:va_operand_vec_opr -> Tot va_code | let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src)) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 26,
"end_line": 44,
"start_col": 0,
"start_line": 43
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Machine_s.Ins",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.Semantics_s.Mfvsrd",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_Mfvsrd dst src =
| (Ins (S.Mfvsrd dst src)) | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_code_Mtvsrdd | val va_code_Mtvsrdd : dst:va_operand_vec_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr
-> Tot va_code | val va_code_Mtvsrdd : dst:va_operand_vec_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr
-> Tot va_code | let va_code_Mtvsrdd dst src1 src2 =
(Ins (S.Mtvsrdd dst src1 src2)) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 104,
"start_col": 0,
"start_line": 103
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld
[@ "opaque_to_smt"]
let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrld dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrld va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrld) (va_code_Mfvsrld dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrld dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrld dst src)) va_s0 in
Vale.Arch.Types.lo64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrld dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrld (va_code_Mfvsrld 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrdd | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src1: Vale.PPC64LE.Decls.va_operand_reg_opr ->
src2: Vale.PPC64LE.Decls.va_operand_reg_opr
-> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Machine_s.Ins",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.Semantics_s.Mtvsrdd",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_Mtvsrdd dst src1 src2 =
| (Ins (S.Mtvsrdd dst src1 src2)) | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_codegen_success_Mfvsrld | val va_codegen_success_Mfvsrld : dst:va_operand_reg_opr -> src:va_operand_vec_opr -> Tot va_pbool | val va_codegen_success_Mfvsrld : dst:va_operand_reg_opr -> src:va_operand_vec_opr -> Tot va_pbool | let va_codegen_success_Mfvsrld dst src =
(va_ttrue ()) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 78,
"start_col": 0,
"start_line": 77
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld
[@ "opaque_to_smt"]
let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src)) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_Mfvsrld dst src =
| (va_ttrue ()) | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.poly1305_encode_last | val poly1305_encode_last:
#s:field_spec
-> f:felem s
-> len:size_t{v len < 16}
-> b:lbuffer uint8 len ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode (v len) (as_seq h0 b)) | val poly1305_encode_last:
#s:field_spec
-> f:felem s
-> len:size_t{v len < 16}
-> b:lbuffer uint8 len ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode (v len) (as_seq h0 b)) | let poly1305_encode_last #s f len b =
push_frame();
let tmp = create 16ul (u8 0) in
update_sub tmp 0ul len b;
let h0 = ST.get () in
Hacl.Impl.Poly1305.Lemmas.nat_from_bytes_le_eq_lemma (v len) (as_seq h0 b);
assert (BSeq.nat_from_bytes_le (as_seq h0 b) == BSeq.nat_from_bytes_le (as_seq h0 tmp));
assert (BSeq.nat_from_bytes_le (as_seq h0 b) < pow2 (v len * 8));
load_felem_le f tmp;
let h1 = ST.get () in
lemma_feval_is_fas_nat h1 f;
set_bit f (len *! 8ul);
pop_frame() | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 200,
"start_col": 0,
"start_line": 187
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s)
unfold
let op_String_Access #a #len = LSeq.index #a #len
let as_get_acc #s h ctx = (feval h (gsub ctx 0ul (nlimb s))).[0]
let as_get_r #s h ctx = (feval h (gsub ctx (nlimb s) (nlimb s))).[0]
let state_inv_t #s h ctx =
felem_fits h (gsub ctx 0ul (nlimb s)) (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h (gsub ctx (nlimb s) (precomplen s))
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --record_options"
let reveal_ctx_inv' #s ctx ctx' h0 h1 =
let acc_b = gsub ctx 0ul (nlimb s) in
let acc_b' = gsub ctx' 0ul (nlimb s) in
let r_b = gsub ctx (nlimb s) (nlimb s) in
let r_b' = gsub ctx' (nlimb s) (nlimb s) in
let precom_b = gsub ctx (nlimb s) (precomplen s) in
let precom_b' = gsub ctx' (nlimb s) (precomplen s) in
as_seq_gsub h0 ctx 0ul (nlimb s);
as_seq_gsub h1 ctx 0ul (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (nlimb s);
as_seq_gsub h1 ctx (nlimb s) (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (precomplen s);
as_seq_gsub h1 ctx (nlimb s) (precomplen s);
as_seq_gsub h0 ctx' 0ul (nlimb s);
as_seq_gsub h1 ctx' 0ul (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (nlimb s);
as_seq_gsub h1 ctx' (nlimb s) (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (precomplen s);
as_seq_gsub h1 ctx' (nlimb s) (precomplen s);
assert (as_seq h0 acc_b == as_seq h1 acc_b');
assert (as_seq h0 r_b == as_seq h1 r_b');
assert (as_seq h0 precom_b == as_seq h1 precom_b')
val fmul_precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.fmul_precomp_r_pre #(width s) h precomp_b)
let fmul_precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let r_b5 = gsub precomp_b (nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (nlimb s) (nlimb s);
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h r_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h r_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h r_b))
val precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.load_precompute_r_post #(width s) h precomp_b)
#push-options "--z3rlimit 150"
let precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let rn_b = gsub precomp_b (2ul *! nlimb s) (nlimb s) in
let rn_b5 = gsub precomp_b (3ul *! nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (2ul *! nlimb s) (nlimb s);
as_seq_gsub h precomp_b (3ul *! nlimb s) (nlimb s);
fmul_precomp_inv_zeros #s precomp_b h;
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h rn_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h rn_b));
assert (feval h rn_b == Vec.compute_rw (feval h r_b).[0])
#pop-options
let ctx_inv_zeros #s ctx h =
// ctx = [acc_b; r_b; r_b5; rn_b; rn_b5]
let acc_b = gsub ctx 0ul (nlimb s) in
as_seq_gsub h ctx 0ul (nlimb s);
LSeq.eq_intro (feval h acc_b) (LSeq.create (width s) 0);
assert (felem_fits h acc_b (2, 2, 2, 2, 2));
let precomp_b = gsub ctx (nlimb s) (precomplen s) in
LSeq.eq_intro (as_seq h precomp_b) (Lib.Sequence.create (v (precomplen s)) (limb_zero s));
precomp_inv_zeros #s precomp_b h
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
val poly1305_encode_block:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode 16 (as_seq h0 b))
let poly1305_encode_block #s f b =
load_felem_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_blocks:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 (blocklen s) ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
feval h1 f == Vec.load_blocks #(width s) (as_seq h0 b))
let poly1305_encode_blocks #s f b =
load_felems_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_last:
#s:field_spec
-> f:felem s
-> len:size_t{v len < 16}
-> b:lbuffer uint8 len ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode (v len) (as_seq h0 b)) | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
f: Hacl.Impl.Poly1305.Fields.felem s ->
len: Lib.IntTypes.size_t{Lib.IntTypes.v len < 16} ->
b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"Hacl.Impl.Poly1305.Fields.felem",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Poly1305.Fields.set_bit",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Poly1305.Fields.lemma_feval_is_fas_nat",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.Poly1305.Fields.load_felem_le",
"Prims._assert",
"Lib.ByteSequence.nat_from_bytes_le",
"Lib.IntTypes.SEC",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.pow2",
"FStar.Mul.op_Star",
"Prims.eq2",
"Prims.nat",
"Prims.l_or",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Hacl.Impl.Poly1305.Lemmas.nat_from_bytes_le_eq_lemma",
"Lib.Buffer.update_sub",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let poly1305_encode_last #s f len b =
| push_frame ();
let tmp = create 16ul (u8 0) in
update_sub tmp 0ul len b;
let h0 = ST.get () in
Hacl.Impl.Poly1305.Lemmas.nat_from_bytes_le_eq_lemma (v len) (as_seq h0 b);
assert (BSeq.nat_from_bytes_le (as_seq h0 b) == BSeq.nat_from_bytes_le (as_seq h0 tmp));
assert (BSeq.nat_from_bytes_le (as_seq h0 b) < pow2 (v len * 8));
load_felem_le f tmp;
let h1 = ST.get () in
lemma_feval_is_fas_nat h1 f;
set_bit f (len *! 8ul);
pop_frame () | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_codegen_success_Mtvsrdd | val va_codegen_success_Mtvsrdd : dst:va_operand_vec_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_pbool | val va_codegen_success_Mtvsrdd : dst:va_operand_vec_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_pbool | let va_codegen_success_Mtvsrdd dst src1 src2 =
(va_ttrue ()) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 108,
"start_col": 0,
"start_line": 107
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld
[@ "opaque_to_smt"]
let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrld dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrld va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrld) (va_code_Mfvsrld dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrld dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrld dst src)) va_s0 in
Vale.Arch.Types.lo64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrld dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrld (va_code_Mfvsrld 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrdd
[@ "opaque_to_smt"]
let va_code_Mtvsrdd dst src1 src2 =
(Ins (S.Mtvsrdd dst src1 src2)) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src1: Vale.PPC64LE.Decls.va_operand_reg_opr ->
src2: Vale.PPC64LE.Decls.va_operand_reg_opr
-> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_Mtvsrdd dst src1 src2 =
| (va_ttrue ()) | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_codegen_success_Mtvsrws | val va_codegen_success_Mtvsrws : dst:va_operand_vec_opr -> src:va_operand_reg_opr -> Tot va_pbool | val va_codegen_success_Mtvsrws : dst:va_operand_vec_opr -> src:va_operand_reg_opr -> Tot va_pbool | let va_codegen_success_Mtvsrws dst src =
(va_ttrue ()) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 137,
"start_col": 0,
"start_line": 136
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld
[@ "opaque_to_smt"]
let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrld dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrld va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrld) (va_code_Mfvsrld dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrld dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrld dst src)) va_s0 in
Vale.Arch.Types.lo64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrld dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrld (va_code_Mfvsrld 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrdd
[@ "opaque_to_smt"]
let va_code_Mtvsrdd dst src1 src2 =
(Ins (S.Mtvsrdd dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrdd dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrdd va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Mtvsrdd) (va_code_Mtvsrdd dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrdd dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrdd dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrdd dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrdd (va_code_Mtvsrdd 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrws
[@ "opaque_to_smt"]
let va_code_Mtvsrws dst src =
(Ins (S.Mtvsrws dst src)) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.PPC64LE.Decls.va_operand_vec_opr -> src: Vale.PPC64LE.Decls.va_operand_reg_opr
-> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_Mtvsrws dst src =
| (va_ttrue ()) | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.mod_mult_congr_aux | val mod_mult_congr_aux (p:int{is_prime p}) (a b c:int) : Lemma
(requires (a * c) % p = (b * c) % p /\ 0 <= b /\ b <= a /\ a < p /\ c % p <> 0)
(ensures a = b) | val mod_mult_congr_aux (p:int{is_prime p}) (a b c:int) : Lemma
(requires (a * c) % p = (b * c) % p /\ 0 <= b /\ b <= a /\ a < p /\ c % p <> 0)
(ensures a = b) | let mod_mult_congr_aux p a b c =
let open FStar.Math.Lemmas in
calc (==>) {
(a * c) % p == (b * c) % p;
==> { mod_add_both (a * c) (b * c) (-b * c) p }
(a * c - b * c) % p == (b * c - b * c) % p;
==> { swap_mul a c; swap_mul b c; lemma_mul_sub_distr c a b }
(c * (a - b)) % p == (b * c - b * c) % p;
==> { small_mod 0 p; lemma_mod_mul_distr_l c (a - b) p }
(c % p * (a - b)) % p == 0;
};
let r, s = FStar.Math.Euclid.bezout_prime p (c % p) in
FStar.Math.Euclid.euclid p (c % p) (a - b) r s;
small_mod (a - b) p | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 21,
"end_line": 493,
"start_col": 0,
"start_line": 480
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n
val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m))
let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
}
val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a))
let rec sum a b f =
if a = b then f a else f a + sum (a + 1) b f
val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g)
(decreases (b - a))
let rec sum_extensionality a b f g =
if a = b then ()
else sum_extensionality (a + 1) b f g
val sum_first (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(sum a b f == f a + sum (a + 1) b f)
let sum_first a b f = ()
val sum_last (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum a (b - 1) f + f b)
(decreases (b - a))
let rec sum_last a b f =
if a + 1 = b then sum_first a b f
else sum_last (a + 1) b f
val sum_const (a:nat) (b:nat{a <= b}) (k:int) : Lemma
(ensures sum a b (fun i -> k) == k * (b - a + 1))
(decreases (b - a))
let rec sum_const a b k =
if a = b then ()
else
begin
sum_const (a + 1) b k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k)
end
val sum_scale (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (k:int) : Lemma
(ensures k * sum a b f == sum a b (fun i -> k * f i))
(decreases (b - a))
let rec sum_scale a b f k =
if a = b then ()
else
begin
sum_scale (a + 1) b f k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k * f i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k * f i)
end
val sum_add (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f + sum a b g == sum a b (fun i -> f i + g i))
(decreases (b - a))
let rec sum_add a b f g =
if a = b then ()
else
begin
sum_add (a + 1) b f g;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> f i + g i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> f i + g i)
end
val sum_shift (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum (a + 1) (b + 1) (fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1)))
(decreases (b - a))
let rec sum_shift a b f =
if a = b then ()
else
begin
sum_shift (a + 1) b f;
sum_extensionality (a + 2) (b + 1)
(fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1))
(fun (i:nat{a + 1 + 1 <= i /\ i <= b + 1}) -> f (i - 1))
end
val sum_mod (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (n:pos) : Lemma
(ensures sum a b f % n == sum a b (fun i -> f i % n) % n)
(decreases (b - a))
let rec sum_mod a b f n =
if a = b then ()
else
let g = fun (i:nat{a <= i /\ i <= b}) -> f i % n in
let f' = fun (i:nat{a + 1 <= i /\ i <= b}) -> f i % n in
calc (==) {
sum a b f % n;
== { sum_first a b f }
(f a + sum (a + 1) b f) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b f) n }
(f a + (sum (a + 1) b f) % n) % n;
== { sum_mod (a + 1) b f n; sum_extensionality (a + 1) b f' g }
(f a + sum (a + 1) b g % n) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b g) n }
(f a + sum (a + 1) b g) % n;
== { lemma_mod_plus_distr_l (f a) (sum (a + 1) b g) n }
(f a % n + sum (a + 1) b g) % n;
== { }
sum a b g % n;
}
val binomial_theorem_aux (a b:int) (n:nat) (i:nat{1 <= i /\ i <= n - 1}) : Lemma
(a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)) ==
binomial n i * pow a (n - i) * pow b i)
let binomial_theorem_aux a b n i =
let open FStar.Math.Lemmas in
calc (==) {
a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1));
== { }
a * (binomial (n - 1) i * pow a ((n - i) - 1) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - i) * pow b (i - 1));
== { _ by (FStar.Tactics.CanonCommSemiring.int_semiring()) }
binomial (n - 1) i * ((a * pow a ((n - i) - 1)) * pow b i) +
binomial (n - 1) (i - 1) * (pow a (n - i) * (b * pow b (i - 1)));
== { assert (a * pow a ((n - i) - 1) == pow a (n - i)); assert (b * pow b (i - 1) == pow b i) }
binomial (n - 1) i * (pow a (n - i) * pow b i) +
binomial (n - 1) (i - 1) * (pow a (n - i) * pow b i);
== { _ by (FStar.Tactics.CanonCommSemiring.int_semiring()) }
(binomial (n - 1) i + binomial (n - 1) (i - 1)) * (pow a (n - i) * pow b i);
== { pascal (n - 1) i }
binomial n i * (pow a (n - i) * pow b i);
== { paren_mul_right (binomial n i) (pow a (n - i)) (pow b i) }
binomial n i * pow a (n - i) * pow b i;
}
#push-options "--fuel 2"
val binomial_theorem (a b:int) (n:nat) : Lemma
(pow (a + b) n == sum 0 n (fun i -> binomial n i * pow a (n - i) * pow b i))
let rec binomial_theorem a b n =
if n = 0 then ()
else
if n = 1 then
(binomial_n 1; binomial_0 1)
else
let reorder (a b c d:int) : Lemma (a + b + (c + d) == a + d + (b + c)) =
assert (a + b + (c + d) == a + d + (b + c)) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
pow (a + b) n;
== { }
(a + b) * pow (a + b) (n - 1);
== { distributivity_add_left a b (pow (a + b) (n - 1)) }
a * pow (a + b) (n - 1) + b * pow (a + b) (n - 1);
== { binomial_theorem a b (n - 1) }
a * sum 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * sum 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i);
== { sum_scale 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) a;
sum_scale 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) b
}
sum 0 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
sum 0 (n - 1) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
== { sum_first 0 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_last 0 (n - 1) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun (i:nat{0 <= i /\ i <= n - 1}) -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 0 (n - 2)
(fun (i:nat{0 <= i /\ i <= n - 2}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun (i:nat{0 <= i /\ i <= n - 1}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))}
(a * (binomial (n - 0) 0 * pow a (n - 1 - 0) * pow b 0)) + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) + b * (binomial (n - 1) (n - 1) * pow a (n - 1 - (n - 1)) * pow b (n - 1)));
== { binomial_0 n; binomial_n (n - 1) }
pow a n + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) + pow b n);
== { sum_shift 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> (fun (i:nat{0 <= i /\ i <= n - 2}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) (i - 1))
(fun (i:nat{1 <= i /\ i <= n - 2 + 1}) -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
}
pow a n + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 1 (n - 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))) + pow b n);
== { reorder (pow a n)
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)))
(sum 1 (n - 2 + 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))))
(pow b n)
}
a * pow a (n - 1) + b * pow b (n - 1) +
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
sum 1 (n - 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))));
== { sum_add 1 (n - 1)
(fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
}
pow a n + pow b n +
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))));
== { Classical.forall_intro (binomial_theorem_aux a b n);
sum_extensionality 1 (n - 1)
(fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
(fun i -> binomial n i * pow a (n - i) * pow b i)
}
pow a n + pow b n + sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i);
== { }
pow a n + (sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i) + pow b n);
== { binomial_0 n; binomial_n n }
binomial n 0 * pow a (n - 0) * pow b 0 +
(sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i) +
binomial n n * pow a (n - n) * pow b n);
== { sum_first 0 n (fun i -> binomial n i * pow a (n - i) * pow b i);
sum_last 1 n (fun i -> binomial n i * pow a (n - i) * pow b i);
sum_extensionality 1 n
(fun (i:nat{0 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i)
(fun (i:nat{1 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i);
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> binomial n i * pow a (n - i) * pow b i)
}
sum 0 n (fun i -> binomial n i * pow a (n - i) * pow b i);
}
#pop-options
val factorial_mod_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(requires !k % p = 0)
(ensures False)
(decreases k)
let rec factorial_mod_prime p k =
if k = 0 then ()
else
begin
euclid_prime p k !(k - 1);
factorial_mod_prime p (k - 1)
end
val binomial_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(binomial p k % p == 0)
let binomial_prime p k =
calc (==) {
(p * !(p -1)) % p;
== { FStar.Math.Lemmas.lemma_mod_mul_distr_l p (!(p - 1)) p }
(p % p * !(p - 1)) % p;
== { }
(0 * !(p - 1)) % p;
== { }
0;
};
binomial_factorial (p - k) k;
assert (binomial p k * (!k * !(p - k)) == p * !(p - 1));
euclid_prime p (binomial p k) (!k * !(p - k));
if (binomial p k % p <> 0) then
begin
euclid_prime p !k !(p - k);
assert (!k % p = 0 \/ !(p - k) % p = 0);
if !k % p = 0 then
factorial_mod_prime p k
else
factorial_mod_prime p (p - k)
end
val freshman_aux (p:int{is_prime p}) (a b:int) (i:pos{i < p}): Lemma
((binomial p i * pow a (p - i) * pow b i) % p == 0)
let freshman_aux p a b i =
calc (==) {
(binomial p i * pow a (p - i) * pow b i) % p;
== { paren_mul_right (binomial p i) (pow a (p - i)) (pow b i) }
(binomial p i * (pow a (p - i) * pow b i)) % p;
== { lemma_mod_mul_distr_l (binomial p i) (pow a (p - i) * pow b i) p }
(binomial p i % p * (pow a (p - i) * pow b i)) % p;
== { binomial_prime p i }
0;
}
val freshman (p:int{is_prime p}) (a b:int) : Lemma
(pow (a + b) p % p = (pow a p + pow b p) % p)
let freshman p a b =
let f (i:nat{0 <= i /\ i <= p}) = binomial p i * pow a (p - i) * pow b i % p in
Classical.forall_intro (freshman_aux p a b);
calc (==) {
pow (a + b) p % p;
== { binomial_theorem a b p }
sum 0 p (fun i -> binomial p i * pow a (p - i) * pow b i) % p;
== { sum_mod 0 p (fun i -> binomial p i * pow a (p - i) * pow b i) p }
sum 0 p f % p;
== { sum_first 0 p f; sum_last 1 p f }
(f 0 + sum 1 (p - 1) f + f p) % p;
== { sum_extensionality 1 (p - 1) f (fun _ -> 0) }
(f 0 + sum 1 (p - 1) (fun _ -> 0) + f p) % p;
== { sum_const 1 (p - 1) 0 }
(f 0 + f p) % p;
== { }
((binomial p 0 * pow a p * pow b 0) % p +
(binomial p p * pow a 0 * pow b p) % p) % p;
== { binomial_0 p; binomial_n p; small_mod 1 p }
(pow a p % p + pow b p % p) % p;
== { lemma_mod_plus_distr_l (pow a p) (pow b p % p) p;
lemma_mod_plus_distr_r (pow a p) (pow b p) p }
(pow a p + pow b p) % p;
}
val fermat_aux (p:int{is_prime p}) (a:pos{a < p}) : Lemma
(ensures pow a p % p == a % p)
(decreases a)
let rec fermat_aux p a =
if a = 1 then pow_one p
else
calc (==) {
pow a p % p;
== { }
pow ((a - 1) + 1) p % p;
== { freshman p (a - 1) 1 }
(pow (a - 1) p + pow 1 p) % p;
== { pow_one p }
(pow (a - 1) p + 1) % p;
== { lemma_mod_plus_distr_l (pow (a - 1) p) 1 p }
(pow (a - 1) p % p + 1) % p;
== { fermat_aux p (a - 1) }
((a - 1) % p + 1) % p;
== { lemma_mod_plus_distr_l (a - 1) 1 p }
((a - 1) + 1) % p;
== { }
a % p;
}
let fermat p a =
if a % p = 0 then
begin
small_mod 0 p;
pow_mod p a p;
pow_zero p
end
else
calc (==) {
pow a p % p;
== { pow_mod p a p }
pow (a % p) p % p;
== { fermat_aux p (a % p) }
(a % p) % p;
== { lemma_mod_twice a p }
a % p;
}
val mod_mult_congr_aux (p:int{is_prime p}) (a b c:int) : Lemma
(requires (a * c) % p = (b * c) % p /\ 0 <= b /\ b <= a /\ a < p /\ c % p <> 0) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Prims.int{FStar.Math.Euclid.is_prime p} -> a: Prims.int -> b: Prims.int -> c: Prims.int
-> FStar.Pervasives.Lemma
(requires a * c % p = b * c % p /\ 0 <= b /\ b <= a /\ a < p /\ c % p <> 0) (ensures a = b) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.int",
"FStar.Math.Euclid.is_prime",
"FStar.Math.Lemmas.small_mod",
"Prims.op_Subtraction",
"Prims.unit",
"FStar.Math.Euclid.euclid",
"Prims.op_Modulus",
"FStar.Pervasives.Native.tuple2",
"FStar.Math.Euclid.bezout_prime",
"FStar.Calc.calc_finish",
"Prims.logical",
"Prims.l_imp",
"Prims.eq2",
"FStar.Mul.op_Star",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Calc.calc_push_impl",
"Prims.squash",
"FStar.Math.Lemmas.mod_add_both",
"Prims.op_Minus",
"FStar.Math.Lemmas.lemma_mul_sub_distr",
"FStar.Math.Lemmas.swap_mul",
"FStar.Math.Lemmas.lemma_mod_mul_distr_l"
] | [] | false | false | true | false | false | let mod_mult_congr_aux p a b c =
| let open FStar.Math.Lemmas in
calc ( ==> ) {
(a * c) % p == (b * c) % p;
( ==> ) { mod_add_both (a * c) (b * c) (- b * c) p }
(a * c - b * c) % p == (b * c - b * c) % p;
( ==> ) { (swap_mul a c;
swap_mul b c;
lemma_mul_sub_distr c a b) }
(c * (a - b)) % p == (b * c - b * c) % p;
( ==> ) { (small_mod 0 p;
lemma_mod_mul_distr_l c (a - b) p) }
((c % p) * (a - b)) % p == 0;
};
let r, s = FStar.Math.Euclid.bezout_prime p (c % p) in
FStar.Math.Euclid.euclid p (c % p) (a - b) r s;
small_mod (a - b) p | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_code_Mtvsrws | val va_code_Mtvsrws : dst:va_operand_vec_opr -> src:va_operand_reg_opr -> Tot va_code | val va_code_Mtvsrws : dst:va_operand_vec_opr -> src:va_operand_reg_opr -> Tot va_code | let va_code_Mtvsrws dst src =
(Ins (S.Mtvsrws dst src)) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 133,
"start_col": 0,
"start_line": 132
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld
[@ "opaque_to_smt"]
let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrld dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrld va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrld) (va_code_Mfvsrld dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrld dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrld dst src)) va_s0 in
Vale.Arch.Types.lo64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrld dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrld (va_code_Mfvsrld 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrdd
[@ "opaque_to_smt"]
let va_code_Mtvsrdd dst src1 src2 =
(Ins (S.Mtvsrdd dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrdd dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrdd va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Mtvsrdd) (va_code_Mtvsrdd dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrdd dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrdd dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrdd dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrdd (va_code_Mtvsrdd 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrws | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.PPC64LE.Decls.va_operand_vec_opr -> src: Vale.PPC64LE.Decls.va_operand_reg_opr
-> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Machine_s.Ins",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.Semantics_s.Mtvsrws",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_Mtvsrws dst src =
| (Ins (S.Mtvsrws dst src)) | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_code_Vadduwm | val va_code_Vadduwm : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr
-> Tot va_code | val va_code_Vadduwm : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr
-> Tot va_code | let va_code_Vadduwm dst src1 src2 =
(Ins (S.Vadduwm dst src1 src2)) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 162,
"start_col": 0,
"start_line": 161
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld
[@ "opaque_to_smt"]
let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrld dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrld va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrld) (va_code_Mfvsrld dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrld dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrld dst src)) va_s0 in
Vale.Arch.Types.lo64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrld dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrld (va_code_Mfvsrld 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrdd
[@ "opaque_to_smt"]
let va_code_Mtvsrdd dst src1 src2 =
(Ins (S.Mtvsrdd dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrdd dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrdd va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Mtvsrdd) (va_code_Mtvsrdd dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrdd dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrdd dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrdd dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrdd (va_code_Mtvsrdd 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrws
[@ "opaque_to_smt"]
let va_code_Mtvsrws dst src =
(Ins (S.Mtvsrws dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrws dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrws va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mtvsrws) (va_code_Mtvsrws dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrws dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrws dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrws dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrws (va_code_Mtvsrws 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vadduwm | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src1: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src2: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Machine_s.Ins",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.Semantics_s.Vadduwm",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_Vadduwm dst src1 src2 =
| (Ins (S.Vadduwm dst src1 src2)) | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_code_Vxor | val va_code_Vxor : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr ->
Tot va_code | val va_code_Vxor : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr ->
Tot va_code | let va_code_Vxor dst src1 src2 =
(Ins (S.Vxor dst src1 src2)) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 30,
"end_line": 191,
"start_col": 0,
"start_line": 190
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld
[@ "opaque_to_smt"]
let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrld dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrld va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrld) (va_code_Mfvsrld dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrld dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrld dst src)) va_s0 in
Vale.Arch.Types.lo64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrld dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrld (va_code_Mfvsrld 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrdd
[@ "opaque_to_smt"]
let va_code_Mtvsrdd dst src1 src2 =
(Ins (S.Mtvsrdd dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrdd dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrdd va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Mtvsrdd) (va_code_Mtvsrdd dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrdd dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrdd dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrdd dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrdd (va_code_Mtvsrdd 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrws
[@ "opaque_to_smt"]
let va_code_Mtvsrws dst src =
(Ins (S.Mtvsrws dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrws dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrws va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mtvsrws) (va_code_Mtvsrws dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrws dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrws dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrws dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrws (va_code_Mtvsrws 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vadduwm
[@ "opaque_to_smt"]
let va_code_Vadduwm dst src1 src2 =
(Ins (S.Vadduwm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vadduwm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vadduwm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vadduwm) (va_code_Vadduwm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vadduwm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vadduwm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vadduwm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vadduwm (va_code_Vadduwm 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vxor | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src1: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src2: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Machine_s.Ins",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.Semantics_s.Vxor",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_Vxor dst src1 src2 =
| (Ins (S.Vxor dst src1 src2)) | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_codegen_success_Vadduwm | val va_codegen_success_Vadduwm : dst:va_operand_vec_opr -> src1:va_operand_vec_opr ->
src2:va_operand_vec_opr -> Tot va_pbool | val va_codegen_success_Vadduwm : dst:va_operand_vec_opr -> src1:va_operand_vec_opr ->
src2:va_operand_vec_opr -> Tot va_pbool | let va_codegen_success_Vadduwm dst src1 src2 =
(va_ttrue ()) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 166,
"start_col": 0,
"start_line": 165
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld
[@ "opaque_to_smt"]
let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrld dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrld va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrld) (va_code_Mfvsrld dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrld dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrld dst src)) va_s0 in
Vale.Arch.Types.lo64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrld dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrld (va_code_Mfvsrld 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrdd
[@ "opaque_to_smt"]
let va_code_Mtvsrdd dst src1 src2 =
(Ins (S.Mtvsrdd dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrdd dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrdd va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Mtvsrdd) (va_code_Mtvsrdd dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrdd dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrdd dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrdd dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrdd (va_code_Mtvsrdd 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrws
[@ "opaque_to_smt"]
let va_code_Mtvsrws dst src =
(Ins (S.Mtvsrws dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrws dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrws va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mtvsrws) (va_code_Mtvsrws dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrws dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrws dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrws dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrws (va_code_Mtvsrws 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vadduwm
[@ "opaque_to_smt"]
let va_code_Vadduwm dst src1 src2 =
(Ins (S.Vadduwm dst src1 src2)) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src1: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src2: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_Vadduwm dst src1 src2 =
| (va_ttrue ()) | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.fermat_aux | val fermat_aux (p:int{is_prime p}) (a:pos{a < p}) : Lemma
(ensures pow a p % p == a % p)
(decreases a) | val fermat_aux (p:int{is_prime p}) (a:pos{a < p}) : Lemma
(ensures pow a p % p == a % p)
(decreases a) | let rec fermat_aux p a =
if a = 1 then pow_one p
else
calc (==) {
pow a p % p;
== { }
pow ((a - 1) + 1) p % p;
== { freshman p (a - 1) 1 }
(pow (a - 1) p + pow 1 p) % p;
== { pow_one p }
(pow (a - 1) p + 1) % p;
== { lemma_mod_plus_distr_l (pow (a - 1) p) 1 p }
(pow (a - 1) p % p + 1) % p;
== { fermat_aux p (a - 1) }
((a - 1) % p + 1) % p;
== { lemma_mod_plus_distr_l (a - 1) 1 p }
((a - 1) + 1) % p;
== { }
a % p;
} | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 457,
"start_col": 0,
"start_line": 438
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n
val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m))
let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
}
val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a))
let rec sum a b f =
if a = b then f a else f a + sum (a + 1) b f
val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g)
(decreases (b - a))
let rec sum_extensionality a b f g =
if a = b then ()
else sum_extensionality (a + 1) b f g
val sum_first (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(sum a b f == f a + sum (a + 1) b f)
let sum_first a b f = ()
val sum_last (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum a (b - 1) f + f b)
(decreases (b - a))
let rec sum_last a b f =
if a + 1 = b then sum_first a b f
else sum_last (a + 1) b f
val sum_const (a:nat) (b:nat{a <= b}) (k:int) : Lemma
(ensures sum a b (fun i -> k) == k * (b - a + 1))
(decreases (b - a))
let rec sum_const a b k =
if a = b then ()
else
begin
sum_const (a + 1) b k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k)
end
val sum_scale (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (k:int) : Lemma
(ensures k * sum a b f == sum a b (fun i -> k * f i))
(decreases (b - a))
let rec sum_scale a b f k =
if a = b then ()
else
begin
sum_scale (a + 1) b f k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k * f i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k * f i)
end
val sum_add (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f + sum a b g == sum a b (fun i -> f i + g i))
(decreases (b - a))
let rec sum_add a b f g =
if a = b then ()
else
begin
sum_add (a + 1) b f g;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> f i + g i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> f i + g i)
end
val sum_shift (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum (a + 1) (b + 1) (fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1)))
(decreases (b - a))
let rec sum_shift a b f =
if a = b then ()
else
begin
sum_shift (a + 1) b f;
sum_extensionality (a + 2) (b + 1)
(fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1))
(fun (i:nat{a + 1 + 1 <= i /\ i <= b + 1}) -> f (i - 1))
end
val sum_mod (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (n:pos) : Lemma
(ensures sum a b f % n == sum a b (fun i -> f i % n) % n)
(decreases (b - a))
let rec sum_mod a b f n =
if a = b then ()
else
let g = fun (i:nat{a <= i /\ i <= b}) -> f i % n in
let f' = fun (i:nat{a + 1 <= i /\ i <= b}) -> f i % n in
calc (==) {
sum a b f % n;
== { sum_first a b f }
(f a + sum (a + 1) b f) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b f) n }
(f a + (sum (a + 1) b f) % n) % n;
== { sum_mod (a + 1) b f n; sum_extensionality (a + 1) b f' g }
(f a + sum (a + 1) b g % n) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b g) n }
(f a + sum (a + 1) b g) % n;
== { lemma_mod_plus_distr_l (f a) (sum (a + 1) b g) n }
(f a % n + sum (a + 1) b g) % n;
== { }
sum a b g % n;
}
val binomial_theorem_aux (a b:int) (n:nat) (i:nat{1 <= i /\ i <= n - 1}) : Lemma
(a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)) ==
binomial n i * pow a (n - i) * pow b i)
let binomial_theorem_aux a b n i =
let open FStar.Math.Lemmas in
calc (==) {
a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1));
== { }
a * (binomial (n - 1) i * pow a ((n - i) - 1) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - i) * pow b (i - 1));
== { _ by (FStar.Tactics.CanonCommSemiring.int_semiring()) }
binomial (n - 1) i * ((a * pow a ((n - i) - 1)) * pow b i) +
binomial (n - 1) (i - 1) * (pow a (n - i) * (b * pow b (i - 1)));
== { assert (a * pow a ((n - i) - 1) == pow a (n - i)); assert (b * pow b (i - 1) == pow b i) }
binomial (n - 1) i * (pow a (n - i) * pow b i) +
binomial (n - 1) (i - 1) * (pow a (n - i) * pow b i);
== { _ by (FStar.Tactics.CanonCommSemiring.int_semiring()) }
(binomial (n - 1) i + binomial (n - 1) (i - 1)) * (pow a (n - i) * pow b i);
== { pascal (n - 1) i }
binomial n i * (pow a (n - i) * pow b i);
== { paren_mul_right (binomial n i) (pow a (n - i)) (pow b i) }
binomial n i * pow a (n - i) * pow b i;
}
#push-options "--fuel 2"
val binomial_theorem (a b:int) (n:nat) : Lemma
(pow (a + b) n == sum 0 n (fun i -> binomial n i * pow a (n - i) * pow b i))
let rec binomial_theorem a b n =
if n = 0 then ()
else
if n = 1 then
(binomial_n 1; binomial_0 1)
else
let reorder (a b c d:int) : Lemma (a + b + (c + d) == a + d + (b + c)) =
assert (a + b + (c + d) == a + d + (b + c)) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
pow (a + b) n;
== { }
(a + b) * pow (a + b) (n - 1);
== { distributivity_add_left a b (pow (a + b) (n - 1)) }
a * pow (a + b) (n - 1) + b * pow (a + b) (n - 1);
== { binomial_theorem a b (n - 1) }
a * sum 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * sum 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i);
== { sum_scale 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) a;
sum_scale 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) b
}
sum 0 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
sum 0 (n - 1) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
== { sum_first 0 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_last 0 (n - 1) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun (i:nat{0 <= i /\ i <= n - 1}) -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 0 (n - 2)
(fun (i:nat{0 <= i /\ i <= n - 2}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun (i:nat{0 <= i /\ i <= n - 1}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))}
(a * (binomial (n - 0) 0 * pow a (n - 1 - 0) * pow b 0)) + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) + b * (binomial (n - 1) (n - 1) * pow a (n - 1 - (n - 1)) * pow b (n - 1)));
== { binomial_0 n; binomial_n (n - 1) }
pow a n + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) + pow b n);
== { sum_shift 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> (fun (i:nat{0 <= i /\ i <= n - 2}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) (i - 1))
(fun (i:nat{1 <= i /\ i <= n - 2 + 1}) -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
}
pow a n + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 1 (n - 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))) + pow b n);
== { reorder (pow a n)
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)))
(sum 1 (n - 2 + 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))))
(pow b n)
}
a * pow a (n - 1) + b * pow b (n - 1) +
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
sum 1 (n - 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))));
== { sum_add 1 (n - 1)
(fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
}
pow a n + pow b n +
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))));
== { Classical.forall_intro (binomial_theorem_aux a b n);
sum_extensionality 1 (n - 1)
(fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
(fun i -> binomial n i * pow a (n - i) * pow b i)
}
pow a n + pow b n + sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i);
== { }
pow a n + (sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i) + pow b n);
== { binomial_0 n; binomial_n n }
binomial n 0 * pow a (n - 0) * pow b 0 +
(sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i) +
binomial n n * pow a (n - n) * pow b n);
== { sum_first 0 n (fun i -> binomial n i * pow a (n - i) * pow b i);
sum_last 1 n (fun i -> binomial n i * pow a (n - i) * pow b i);
sum_extensionality 1 n
(fun (i:nat{0 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i)
(fun (i:nat{1 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i);
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> binomial n i * pow a (n - i) * pow b i)
}
sum 0 n (fun i -> binomial n i * pow a (n - i) * pow b i);
}
#pop-options
val factorial_mod_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(requires !k % p = 0)
(ensures False)
(decreases k)
let rec factorial_mod_prime p k =
if k = 0 then ()
else
begin
euclid_prime p k !(k - 1);
factorial_mod_prime p (k - 1)
end
val binomial_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(binomial p k % p == 0)
let binomial_prime p k =
calc (==) {
(p * !(p -1)) % p;
== { FStar.Math.Lemmas.lemma_mod_mul_distr_l p (!(p - 1)) p }
(p % p * !(p - 1)) % p;
== { }
(0 * !(p - 1)) % p;
== { }
0;
};
binomial_factorial (p - k) k;
assert (binomial p k * (!k * !(p - k)) == p * !(p - 1));
euclid_prime p (binomial p k) (!k * !(p - k));
if (binomial p k % p <> 0) then
begin
euclid_prime p !k !(p - k);
assert (!k % p = 0 \/ !(p - k) % p = 0);
if !k % p = 0 then
factorial_mod_prime p k
else
factorial_mod_prime p (p - k)
end
val freshman_aux (p:int{is_prime p}) (a b:int) (i:pos{i < p}): Lemma
((binomial p i * pow a (p - i) * pow b i) % p == 0)
let freshman_aux p a b i =
calc (==) {
(binomial p i * pow a (p - i) * pow b i) % p;
== { paren_mul_right (binomial p i) (pow a (p - i)) (pow b i) }
(binomial p i * (pow a (p - i) * pow b i)) % p;
== { lemma_mod_mul_distr_l (binomial p i) (pow a (p - i) * pow b i) p }
(binomial p i % p * (pow a (p - i) * pow b i)) % p;
== { binomial_prime p i }
0;
}
val freshman (p:int{is_prime p}) (a b:int) : Lemma
(pow (a + b) p % p = (pow a p + pow b p) % p)
let freshman p a b =
let f (i:nat{0 <= i /\ i <= p}) = binomial p i * pow a (p - i) * pow b i % p in
Classical.forall_intro (freshman_aux p a b);
calc (==) {
pow (a + b) p % p;
== { binomial_theorem a b p }
sum 0 p (fun i -> binomial p i * pow a (p - i) * pow b i) % p;
== { sum_mod 0 p (fun i -> binomial p i * pow a (p - i) * pow b i) p }
sum 0 p f % p;
== { sum_first 0 p f; sum_last 1 p f }
(f 0 + sum 1 (p - 1) f + f p) % p;
== { sum_extensionality 1 (p - 1) f (fun _ -> 0) }
(f 0 + sum 1 (p - 1) (fun _ -> 0) + f p) % p;
== { sum_const 1 (p - 1) 0 }
(f 0 + f p) % p;
== { }
((binomial p 0 * pow a p * pow b 0) % p +
(binomial p p * pow a 0 * pow b p) % p) % p;
== { binomial_0 p; binomial_n p; small_mod 1 p }
(pow a p % p + pow b p % p) % p;
== { lemma_mod_plus_distr_l (pow a p) (pow b p % p) p;
lemma_mod_plus_distr_r (pow a p) (pow b p) p }
(pow a p + pow b p) % p;
}
val fermat_aux (p:int{is_prime p}) (a:pos{a < p}) : Lemma
(ensures pow a p % p == a % p) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Prims.int{FStar.Math.Euclid.is_prime p} -> a: Prims.pos{a < p}
-> FStar.Pervasives.Lemma (ensures FStar.Math.Fermat.pow a p % p == a % p) (decreases a) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Prims.int",
"FStar.Math.Euclid.is_prime",
"Prims.pos",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Equality",
"FStar.Math.Fermat.pow_one",
"Prims.bool",
"FStar.Calc.calc_finish",
"Prims.eq2",
"Prims.op_Modulus",
"FStar.Math.Fermat.pow",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Prims.op_Addition",
"Prims.op_Subtraction",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"FStar.Math.Fermat.freshman",
"FStar.Math.Lemmas.lemma_mod_plus_distr_l",
"FStar.Math.Fermat.fermat_aux"
] | [
"recursion"
] | false | false | true | false | false | let rec fermat_aux p a =
| if a = 1
then pow_one p
else
calc ( == ) {
pow a p % p;
( == ) { () }
pow ((a - 1) + 1) p % p;
( == ) { freshman p (a - 1) 1 }
(pow (a - 1) p + pow 1 p) % p;
( == ) { pow_one p }
(pow (a - 1) p + 1) % p;
( == ) { lemma_mod_plus_distr_l (pow (a - 1) p) 1 p }
(pow (a - 1) p % p + 1) % p;
( == ) { fermat_aux p (a - 1) }
((a - 1) % p + 1) % p;
( == ) { lemma_mod_plus_distr_l (a - 1) 1 p }
((a - 1) + 1) % p;
( == ) { () }
a % p;
} | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_codegen_success_Vxor | val va_codegen_success_Vxor : dst:va_operand_vec_opr -> src1:va_operand_vec_opr ->
src2:va_operand_vec_opr -> Tot va_pbool | val va_codegen_success_Vxor : dst:va_operand_vec_opr -> src1:va_operand_vec_opr ->
src2:va_operand_vec_opr -> Tot va_pbool | let va_codegen_success_Vxor dst src1 src2 =
(va_ttrue ()) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 195,
"start_col": 0,
"start_line": 194
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld
[@ "opaque_to_smt"]
let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrld dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrld va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrld) (va_code_Mfvsrld dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrld dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrld dst src)) va_s0 in
Vale.Arch.Types.lo64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrld dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrld (va_code_Mfvsrld 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrdd
[@ "opaque_to_smt"]
let va_code_Mtvsrdd dst src1 src2 =
(Ins (S.Mtvsrdd dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrdd dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrdd va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Mtvsrdd) (va_code_Mtvsrdd dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrdd dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrdd dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrdd dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrdd (va_code_Mtvsrdd 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrws
[@ "opaque_to_smt"]
let va_code_Mtvsrws dst src =
(Ins (S.Mtvsrws dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrws dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrws va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mtvsrws) (va_code_Mtvsrws dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrws dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrws dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrws dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrws (va_code_Mtvsrws 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vadduwm
[@ "opaque_to_smt"]
let va_code_Vadduwm dst src1 src2 =
(Ins (S.Vadduwm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vadduwm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vadduwm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vadduwm) (va_code_Vadduwm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vadduwm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vadduwm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vadduwm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vadduwm (va_code_Vadduwm 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vxor
[@ "opaque_to_smt"]
let va_code_Vxor dst src1 src2 =
(Ins (S.Vxor dst src1 src2)) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src1: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src2: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_Vxor dst src1 src2 =
| (va_ttrue ()) | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.fermat_alt | val fermat_alt (p:int{is_prime p}) (a:int{a % p <> 0}) : Lemma (pow a (p - 1) % p == 1) | val fermat_alt (p:int{is_prime p}) (a:int{a % p <> 0}) : Lemma (pow a (p - 1) % p == 1) | let fermat_alt p a =
calc (==) {
(pow a (p - 1) * a) % p;
== { lemma_mod_mul_distr_r (pow a (p - 1)) a p;
lemma_mod_mul_distr_l (pow a (p - 1)) (a % p) p
}
((pow a (p - 1) % p) * (a % p)) % p;
== { pow_mod p a (p - 1) }
((pow (a % p) (p - 1) % p) * (a % p)) % p;
== { lemma_mod_mul_distr_l (pow (a % p) (p - 1)) (a % p) p }
(pow (a % p) (p - 1) * (a % p)) % p;
== { }
pow (a % p) p % p;
== { fermat p (a % p) }
(a % p) % p;
== { lemma_mod_twice a p }
a % p;
== { }
(1 * a) % p;
};
small_mod 1 p;
mod_mult_congr p (pow a (p - 1)) 1 a | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 38,
"end_line": 524,
"start_col": 0,
"start_line": 503
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n
val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m))
let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
}
val sum: a:nat -> b:nat{a <= b} -> f:((i:nat{a <= i /\ i <= b}) -> int)
-> Tot int (decreases (b - a))
let rec sum a b f =
if a = b then f a else f a + sum (a + 1) b f
val sum_extensionality (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(requires forall (i:nat{a <= i /\ i <= b}). f i == g i)
(ensures sum a b f == sum a b g)
(decreases (b - a))
let rec sum_extensionality a b f g =
if a = b then ()
else sum_extensionality (a + 1) b f g
val sum_first (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(sum a b f == f a + sum (a + 1) b f)
let sum_first a b f = ()
val sum_last (a:nat) (b:nat{a < b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum a (b - 1) f + f b)
(decreases (b - a))
let rec sum_last a b f =
if a + 1 = b then sum_first a b f
else sum_last (a + 1) b f
val sum_const (a:nat) (b:nat{a <= b}) (k:int) : Lemma
(ensures sum a b (fun i -> k) == k * (b - a + 1))
(decreases (b - a))
let rec sum_const a b k =
if a = b then ()
else
begin
sum_const (a + 1) b k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k)
end
val sum_scale (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (k:int) : Lemma
(ensures k * sum a b f == sum a b (fun i -> k * f i))
(decreases (b - a))
let rec sum_scale a b f k =
if a = b then ()
else
begin
sum_scale (a + 1) b f k;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> k * f i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> k * f i)
end
val sum_add (a:nat) (b:nat{a <= b}) (f g:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f + sum a b g == sum a b (fun i -> f i + g i))
(decreases (b - a))
let rec sum_add a b f g =
if a = b then ()
else
begin
sum_add (a + 1) b f g;
sum_extensionality (a + 1) b
(fun (i:nat{a <= i /\ i <= b}) -> f i + g i)
(fun (i:nat{a + 1 <= i /\ i <= b}) -> f i + g i)
end
val sum_shift (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) : Lemma
(ensures sum a b f == sum (a + 1) (b + 1) (fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1)))
(decreases (b - a))
let rec sum_shift a b f =
if a = b then ()
else
begin
sum_shift (a + 1) b f;
sum_extensionality (a + 2) (b + 1)
(fun (i:nat{a + 1 <= i /\ i <= b + 1}) -> f (i - 1))
(fun (i:nat{a + 1 + 1 <= i /\ i <= b + 1}) -> f (i - 1))
end
val sum_mod (a:nat) (b:nat{a <= b}) (f:(i:nat{a <= i /\ i <= b}) -> int) (n:pos) : Lemma
(ensures sum a b f % n == sum a b (fun i -> f i % n) % n)
(decreases (b - a))
let rec sum_mod a b f n =
if a = b then ()
else
let g = fun (i:nat{a <= i /\ i <= b}) -> f i % n in
let f' = fun (i:nat{a + 1 <= i /\ i <= b}) -> f i % n in
calc (==) {
sum a b f % n;
== { sum_first a b f }
(f a + sum (a + 1) b f) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b f) n }
(f a + (sum (a + 1) b f) % n) % n;
== { sum_mod (a + 1) b f n; sum_extensionality (a + 1) b f' g }
(f a + sum (a + 1) b g % n) % n;
== { lemma_mod_plus_distr_r (f a) (sum (a + 1) b g) n }
(f a + sum (a + 1) b g) % n;
== { lemma_mod_plus_distr_l (f a) (sum (a + 1) b g) n }
(f a % n + sum (a + 1) b g) % n;
== { }
sum a b g % n;
}
val binomial_theorem_aux (a b:int) (n:nat) (i:nat{1 <= i /\ i <= n - 1}) : Lemma
(a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)) ==
binomial n i * pow a (n - i) * pow b i)
let binomial_theorem_aux a b n i =
let open FStar.Math.Lemmas in
calc (==) {
a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1));
== { }
a * (binomial (n - 1) i * pow a ((n - i) - 1) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - i) * pow b (i - 1));
== { _ by (FStar.Tactics.CanonCommSemiring.int_semiring()) }
binomial (n - 1) i * ((a * pow a ((n - i) - 1)) * pow b i) +
binomial (n - 1) (i - 1) * (pow a (n - i) * (b * pow b (i - 1)));
== { assert (a * pow a ((n - i) - 1) == pow a (n - i)); assert (b * pow b (i - 1) == pow b i) }
binomial (n - 1) i * (pow a (n - i) * pow b i) +
binomial (n - 1) (i - 1) * (pow a (n - i) * pow b i);
== { _ by (FStar.Tactics.CanonCommSemiring.int_semiring()) }
(binomial (n - 1) i + binomial (n - 1) (i - 1)) * (pow a (n - i) * pow b i);
== { pascal (n - 1) i }
binomial n i * (pow a (n - i) * pow b i);
== { paren_mul_right (binomial n i) (pow a (n - i)) (pow b i) }
binomial n i * pow a (n - i) * pow b i;
}
#push-options "--fuel 2"
val binomial_theorem (a b:int) (n:nat) : Lemma
(pow (a + b) n == sum 0 n (fun i -> binomial n i * pow a (n - i) * pow b i))
let rec binomial_theorem a b n =
if n = 0 then ()
else
if n = 1 then
(binomial_n 1; binomial_0 1)
else
let reorder (a b c d:int) : Lemma (a + b + (c + d) == a + d + (b + c)) =
assert (a + b + (c + d) == a + d + (b + c)) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
pow (a + b) n;
== { }
(a + b) * pow (a + b) (n - 1);
== { distributivity_add_left a b (pow (a + b) (n - 1)) }
a * pow (a + b) (n - 1) + b * pow (a + b) (n - 1);
== { binomial_theorem a b (n - 1) }
a * sum 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * sum 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i);
== { sum_scale 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) a;
sum_scale 0 (n - 1) (fun i -> binomial (n - 1) i * pow a (n - 1 - i) * pow b i) b
}
sum 0 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
sum 0 (n - 1) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
== { sum_first 0 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_last 0 (n - 1) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun (i:nat{0 <= i /\ i <= n - 1}) -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 0 (n - 2)
(fun (i:nat{0 <= i /\ i <= n - 2}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun (i:nat{0 <= i /\ i <= n - 1}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))}
(a * (binomial (n - 0) 0 * pow a (n - 1 - 0) * pow b 0)) + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) + b * (binomial (n - 1) (n - 1) * pow a (n - 1 - (n - 1)) * pow b (n - 1)));
== { binomial_0 n; binomial_n (n - 1) }
pow a n + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) + pow b n);
== { sum_shift 0 (n - 2) (fun i -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i));
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> (fun (i:nat{0 <= i /\ i <= n - 2}) -> b * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) (i - 1))
(fun (i:nat{1 <= i /\ i <= n - 2 + 1}) -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
}
pow a n + sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
(sum 1 (n - 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))) + pow b n);
== { reorder (pow a n)
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)))
(sum 1 (n - 2 + 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))))
(pow b n)
}
a * pow a (n - 1) + b * pow b (n - 1) +
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i)) +
sum 1 (n - 1) (fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))));
== { sum_add 1 (n - 1)
(fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i))
(fun i -> b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
}
pow a n + pow b n +
(sum 1 (n - 1) (fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1))));
== { Classical.forall_intro (binomial_theorem_aux a b n);
sum_extensionality 1 (n - 1)
(fun i -> a * (binomial (n - 1) i * pow a (n - 1 - i) * pow b i) +
b * (binomial (n - 1) (i - 1) * pow a (n - 1 - (i - 1)) * pow b (i - 1)))
(fun i -> binomial n i * pow a (n - i) * pow b i)
}
pow a n + pow b n + sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i);
== { }
pow a n + (sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i) + pow b n);
== { binomial_0 n; binomial_n n }
binomial n 0 * pow a (n - 0) * pow b 0 +
(sum 1 (n - 1) (fun i -> binomial n i * pow a (n - i) * pow b i) +
binomial n n * pow a (n - n) * pow b n);
== { sum_first 0 n (fun i -> binomial n i * pow a (n - i) * pow b i);
sum_last 1 n (fun i -> binomial n i * pow a (n - i) * pow b i);
sum_extensionality 1 n
(fun (i:nat{0 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i)
(fun (i:nat{1 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i);
sum_extensionality 1 (n - 1)
(fun (i:nat{1 <= i /\ i <= n}) -> binomial n i * pow a (n - i) * pow b i)
(fun (i:nat{1 <= i /\ i <= n - 1}) -> binomial n i * pow a (n - i) * pow b i)
}
sum 0 n (fun i -> binomial n i * pow a (n - i) * pow b i);
}
#pop-options
val factorial_mod_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(requires !k % p = 0)
(ensures False)
(decreases k)
let rec factorial_mod_prime p k =
if k = 0 then ()
else
begin
euclid_prime p k !(k - 1);
factorial_mod_prime p (k - 1)
end
val binomial_prime (p:int{is_prime p}) (k:pos{k < p}) : Lemma
(binomial p k % p == 0)
let binomial_prime p k =
calc (==) {
(p * !(p -1)) % p;
== { FStar.Math.Lemmas.lemma_mod_mul_distr_l p (!(p - 1)) p }
(p % p * !(p - 1)) % p;
== { }
(0 * !(p - 1)) % p;
== { }
0;
};
binomial_factorial (p - k) k;
assert (binomial p k * (!k * !(p - k)) == p * !(p - 1));
euclid_prime p (binomial p k) (!k * !(p - k));
if (binomial p k % p <> 0) then
begin
euclid_prime p !k !(p - k);
assert (!k % p = 0 \/ !(p - k) % p = 0);
if !k % p = 0 then
factorial_mod_prime p k
else
factorial_mod_prime p (p - k)
end
val freshman_aux (p:int{is_prime p}) (a b:int) (i:pos{i < p}): Lemma
((binomial p i * pow a (p - i) * pow b i) % p == 0)
let freshman_aux p a b i =
calc (==) {
(binomial p i * pow a (p - i) * pow b i) % p;
== { paren_mul_right (binomial p i) (pow a (p - i)) (pow b i) }
(binomial p i * (pow a (p - i) * pow b i)) % p;
== { lemma_mod_mul_distr_l (binomial p i) (pow a (p - i) * pow b i) p }
(binomial p i % p * (pow a (p - i) * pow b i)) % p;
== { binomial_prime p i }
0;
}
val freshman (p:int{is_prime p}) (a b:int) : Lemma
(pow (a + b) p % p = (pow a p + pow b p) % p)
let freshman p a b =
let f (i:nat{0 <= i /\ i <= p}) = binomial p i * pow a (p - i) * pow b i % p in
Classical.forall_intro (freshman_aux p a b);
calc (==) {
pow (a + b) p % p;
== { binomial_theorem a b p }
sum 0 p (fun i -> binomial p i * pow a (p - i) * pow b i) % p;
== { sum_mod 0 p (fun i -> binomial p i * pow a (p - i) * pow b i) p }
sum 0 p f % p;
== { sum_first 0 p f; sum_last 1 p f }
(f 0 + sum 1 (p - 1) f + f p) % p;
== { sum_extensionality 1 (p - 1) f (fun _ -> 0) }
(f 0 + sum 1 (p - 1) (fun _ -> 0) + f p) % p;
== { sum_const 1 (p - 1) 0 }
(f 0 + f p) % p;
== { }
((binomial p 0 * pow a p * pow b 0) % p +
(binomial p p * pow a 0 * pow b p) % p) % p;
== { binomial_0 p; binomial_n p; small_mod 1 p }
(pow a p % p + pow b p % p) % p;
== { lemma_mod_plus_distr_l (pow a p) (pow b p % p) p;
lemma_mod_plus_distr_r (pow a p) (pow b p) p }
(pow a p + pow b p) % p;
}
val fermat_aux (p:int{is_prime p}) (a:pos{a < p}) : Lemma
(ensures pow a p % p == a % p)
(decreases a)
let rec fermat_aux p a =
if a = 1 then pow_one p
else
calc (==) {
pow a p % p;
== { }
pow ((a - 1) + 1) p % p;
== { freshman p (a - 1) 1 }
(pow (a - 1) p + pow 1 p) % p;
== { pow_one p }
(pow (a - 1) p + 1) % p;
== { lemma_mod_plus_distr_l (pow (a - 1) p) 1 p }
(pow (a - 1) p % p + 1) % p;
== { fermat_aux p (a - 1) }
((a - 1) % p + 1) % p;
== { lemma_mod_plus_distr_l (a - 1) 1 p }
((a - 1) + 1) % p;
== { }
a % p;
}
let fermat p a =
if a % p = 0 then
begin
small_mod 0 p;
pow_mod p a p;
pow_zero p
end
else
calc (==) {
pow a p % p;
== { pow_mod p a p }
pow (a % p) p % p;
== { fermat_aux p (a % p) }
(a % p) % p;
== { lemma_mod_twice a p }
a % p;
}
val mod_mult_congr_aux (p:int{is_prime p}) (a b c:int) : Lemma
(requires (a * c) % p = (b * c) % p /\ 0 <= b /\ b <= a /\ a < p /\ c % p <> 0)
(ensures a = b)
let mod_mult_congr_aux p a b c =
let open FStar.Math.Lemmas in
calc (==>) {
(a * c) % p == (b * c) % p;
==> { mod_add_both (a * c) (b * c) (-b * c) p }
(a * c - b * c) % p == (b * c - b * c) % p;
==> { swap_mul a c; swap_mul b c; lemma_mul_sub_distr c a b }
(c * (a - b)) % p == (b * c - b * c) % p;
==> { small_mod 0 p; lemma_mod_mul_distr_l c (a - b) p }
(c % p * (a - b)) % p == 0;
};
let r, s = FStar.Math.Euclid.bezout_prime p (c % p) in
FStar.Math.Euclid.euclid p (c % p) (a - b) r s;
small_mod (a - b) p
let mod_mult_congr p a b c =
let open FStar.Math.Lemmas in
lemma_mod_mul_distr_l a c p;
lemma_mod_mul_distr_l b c p;
if a % p = b % p then ()
else if b % p < a % p then mod_mult_congr_aux p (a % p) (b % p) c
else mod_mult_congr_aux p (b % p) (a % p) c | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Prims.int{FStar.Math.Euclid.is_prime p} -> a: Prims.int{a % p <> 0}
-> FStar.Pervasives.Lemma (ensures FStar.Math.Fermat.pow a (p - 1) % p == 1) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.int",
"FStar.Math.Euclid.is_prime",
"Prims.b2t",
"Prims.op_disEquality",
"Prims.op_Modulus",
"FStar.Math.Fermat.mod_mult_congr",
"FStar.Math.Fermat.pow",
"Prims.op_Subtraction",
"Prims.unit",
"FStar.Math.Lemmas.small_mod",
"FStar.Calc.calc_finish",
"Prims.eq2",
"FStar.Mul.op_Star",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Lemmas.lemma_mod_mul_distr_l",
"FStar.Math.Lemmas.lemma_mod_mul_distr_r",
"Prims.squash",
"FStar.Math.Fermat.pow_mod",
"FStar.Math.Fermat.fermat",
"FStar.Math.Lemmas.lemma_mod_twice"
] | [] | false | false | true | false | false | let fermat_alt p a =
| calc ( == ) {
(pow a (p - 1) * a) % p;
( == ) { (lemma_mod_mul_distr_r (pow a (p - 1)) a p;
lemma_mod_mul_distr_l (pow a (p - 1)) (a % p) p) }
((pow a (p - 1) % p) * (a % p)) % p;
( == ) { pow_mod p a (p - 1) }
((pow (a % p) (p - 1) % p) * (a % p)) % p;
( == ) { lemma_mod_mul_distr_l (pow (a % p) (p - 1)) (a % p) p }
(pow (a % p) (p - 1) * (a % p)) % p;
( == ) { () }
pow (a % p) p % p;
( == ) { fermat p (a % p) }
(a % p) % p;
( == ) { lemma_mod_twice a p }
a % p;
( == ) { () }
(1 * a) % p;
};
small_mod 1 p;
mod_mult_congr p (pow a (p - 1)) 1 a | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_code_Vand | val va_code_Vand : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr ->
Tot va_code | val va_code_Vand : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr ->
Tot va_code | let va_code_Vand dst src1 src2 =
(Ins (S.Vand dst src1 src2)) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 30,
"end_line": 220,
"start_col": 0,
"start_line": 219
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld
[@ "opaque_to_smt"]
let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrld dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrld va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrld) (va_code_Mfvsrld dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrld dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrld dst src)) va_s0 in
Vale.Arch.Types.lo64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrld dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrld (va_code_Mfvsrld 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrdd
[@ "opaque_to_smt"]
let va_code_Mtvsrdd dst src1 src2 =
(Ins (S.Mtvsrdd dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrdd dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrdd va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Mtvsrdd) (va_code_Mtvsrdd dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrdd dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrdd dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrdd dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrdd (va_code_Mtvsrdd 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrws
[@ "opaque_to_smt"]
let va_code_Mtvsrws dst src =
(Ins (S.Mtvsrws dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrws dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrws va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mtvsrws) (va_code_Mtvsrws dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrws dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrws dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrws dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrws (va_code_Mtvsrws 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vadduwm
[@ "opaque_to_smt"]
let va_code_Vadduwm dst src1 src2 =
(Ins (S.Vadduwm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vadduwm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vadduwm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vadduwm) (va_code_Vadduwm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vadduwm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vadduwm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vadduwm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vadduwm (va_code_Vadduwm 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vxor
[@ "opaque_to_smt"]
let va_code_Vxor dst src1 src2 =
(Ins (S.Vxor dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vxor dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vxor va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vxor) (va_code_Vxor dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vxor dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vxor dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vxor dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vxor (va_code_Vxor 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vand | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src1: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src2: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Machine_s.Ins",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.Semantics_s.Vand",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_Vand dst src1 src2 =
| (Ins (S.Vand dst src1 src2)) | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_codegen_success_Vand | val va_codegen_success_Vand : dst:va_operand_vec_opr -> src1:va_operand_vec_opr ->
src2:va_operand_vec_opr -> Tot va_pbool | val va_codegen_success_Vand : dst:va_operand_vec_opr -> src1:va_operand_vec_opr ->
src2:va_operand_vec_opr -> Tot va_pbool | let va_codegen_success_Vand dst src1 src2 =
(va_ttrue ()) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 224,
"start_col": 0,
"start_line": 223
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld
[@ "opaque_to_smt"]
let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrld dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrld va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrld) (va_code_Mfvsrld dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrld dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrld dst src)) va_s0 in
Vale.Arch.Types.lo64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrld dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrld (va_code_Mfvsrld 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrdd
[@ "opaque_to_smt"]
let va_code_Mtvsrdd dst src1 src2 =
(Ins (S.Mtvsrdd dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrdd dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrdd va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Mtvsrdd) (va_code_Mtvsrdd dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrdd dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrdd dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrdd dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrdd (va_code_Mtvsrdd 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrws
[@ "opaque_to_smt"]
let va_code_Mtvsrws dst src =
(Ins (S.Mtvsrws dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrws dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrws va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mtvsrws) (va_code_Mtvsrws dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrws dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrws dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrws dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrws (va_code_Mtvsrws 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vadduwm
[@ "opaque_to_smt"]
let va_code_Vadduwm dst src1 src2 =
(Ins (S.Vadduwm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vadduwm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vadduwm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vadduwm) (va_code_Vadduwm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vadduwm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vadduwm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vadduwm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vadduwm (va_code_Vadduwm 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vxor
[@ "opaque_to_smt"]
let va_code_Vxor dst src1 src2 =
(Ins (S.Vxor dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vxor dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vxor va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vxor) (va_code_Vxor dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vxor dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vxor dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vxor dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vxor (va_code_Vxor 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vand
[@ "opaque_to_smt"]
let va_code_Vand dst src1 src2 =
(Ins (S.Vand dst src1 src2)) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src1: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src2: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_Vand dst src1 src2 =
| (va_ttrue ()) | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_codegen_success_Vslw | val va_codegen_success_Vslw : dst:va_operand_vec_opr -> src1:va_operand_vec_opr ->
src2:va_operand_vec_opr -> Tot va_pbool | val va_codegen_success_Vslw : dst:va_operand_vec_opr -> src1:va_operand_vec_opr ->
src2:va_operand_vec_opr -> Tot va_pbool | let va_codegen_success_Vslw dst src1 src2 =
(va_ttrue ()) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 253,
"start_col": 0,
"start_line": 252
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld
[@ "opaque_to_smt"]
let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrld dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrld va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrld) (va_code_Mfvsrld dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrld dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrld dst src)) va_s0 in
Vale.Arch.Types.lo64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrld dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrld (va_code_Mfvsrld 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrdd
[@ "opaque_to_smt"]
let va_code_Mtvsrdd dst src1 src2 =
(Ins (S.Mtvsrdd dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrdd dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrdd va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Mtvsrdd) (va_code_Mtvsrdd dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrdd dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrdd dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrdd dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrdd (va_code_Mtvsrdd 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrws
[@ "opaque_to_smt"]
let va_code_Mtvsrws dst src =
(Ins (S.Mtvsrws dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrws dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrws va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mtvsrws) (va_code_Mtvsrws dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrws dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrws dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrws dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrws (va_code_Mtvsrws 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vadduwm
[@ "opaque_to_smt"]
let va_code_Vadduwm dst src1 src2 =
(Ins (S.Vadduwm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vadduwm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vadduwm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vadduwm) (va_code_Vadduwm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vadduwm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vadduwm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vadduwm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vadduwm (va_code_Vadduwm 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vxor
[@ "opaque_to_smt"]
let va_code_Vxor dst src1 src2 =
(Ins (S.Vxor dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vxor dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vxor va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vxor) (va_code_Vxor dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vxor dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vxor dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vxor dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vxor (va_code_Vxor 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vand
[@ "opaque_to_smt"]
let va_code_Vand dst src1 src2 =
(Ins (S.Vand dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vand dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vand va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vand) (va_code_Vand dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vand dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vand dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vand dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vand (va_code_Vand 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vslw
[@ "opaque_to_smt"]
let va_code_Vslw dst src1 src2 =
(Ins (S.Vslw dst src1 src2)) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src1: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src2: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_Vslw dst src1 src2 =
| (va_ttrue ()) | false |
FStar.Math.Fermat.fst | FStar.Math.Fermat.binomial_factorial | val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m)) | val binomial_factorial (m n:nat) : Lemma (binomial (n + m) n * (!n * !m) == !(n + m)) | let rec binomial_factorial m n =
match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d:int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
assert (a * (b * (c * d)) == c * (a * (b * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
let reorder2 (a b c d:int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
assert (a * ((b * c) * d) == b * (a * (c * d))) by (FStar.Tactics.CanonCommSemiring.int_semiring())
in
calc (==) {
binomial (n + m) n * (!n * !m);
== { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
== { addition_is_associative n m (-1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
== { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m)
}
binomial (n + (m - 1)) n * (!n * !m) +
binomial (n + (m - 1)) (n - 1) * (!n * !m);
== { }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
== { reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)
}
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
== { binomial_factorial (m - 1) n; binomial_factorial m (n - 1) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
== { }
m * !(n + m - 1) + n * !(n + m - 1);
== { }
n * !(n + m - 1) + m * !(n + m - 1);
== { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
== { }
!(n + m);
} | {
"file_name": "ulib/FStar.Math.Fermat.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 140,
"start_col": 0,
"start_line": 98
} | module FStar.Math.Fermat
open FStar.Mul
open FStar.Math.Lemmas
open FStar.Math.Euclid
#set-options "--fuel 1 --ifuel 0 --z3rlimit 20"
///
/// Pow
///
val pow_zero (k:pos) : Lemma (ensures pow 0 k == 0) (decreases k)
let rec pow_zero k =
match k with
| 1 -> ()
| _ -> pow_zero (k - 1)
val pow_one (k:nat) : Lemma (pow 1 k == 1)
let rec pow_one = function
| 0 -> ()
| k -> pow_one (k - 1)
val pow_plus (a:int) (k m:nat): Lemma (pow a (k + m) == pow a k * pow a m)
let rec pow_plus a k m =
match k with
| 0 -> ()
| _ ->
calc (==) {
pow a (k + m);
== { }
a * pow a ((k + m) - 1);
== { pow_plus a (k - 1) m }
a * (pow a (k - 1) * pow a m);
== { }
pow a k * pow a m;
}
val pow_mod (p:pos) (a:int) (k:nat) : Lemma (pow a k % p == pow (a % p) k % p)
let rec pow_mod p a k =
if k = 0 then ()
else
calc (==) {
pow a k % p;
== { }
a * pow a (k - 1) % p;
== { lemma_mod_mul_distr_r a (pow a (k - 1)) p }
(a * (pow a (k - 1) % p)) % p;
== { pow_mod p a (k - 1) }
(a * (pow (a % p) (k - 1) % p)) % p;
== { lemma_mod_mul_distr_r a (pow (a % p) (k - 1)) p }
a * pow (a % p) (k - 1) % p;
== { lemma_mod_mul_distr_l a (pow (a % p) (k - 1)) p }
(a % p * pow (a % p) (k - 1)) % p;
== { }
pow (a % p) k % p;
}
///
/// Binomial theorem
///
val binomial (n k:nat) : nat
let rec binomial n k =
match n, k with
| _, 0 -> 1
| 0, _ -> 0
| _, _ -> binomial (n - 1) k + binomial (n - 1) (k - 1)
val binomial_0 (n:nat) : Lemma (binomial n 0 == 1)
let binomial_0 n = ()
val binomial_lt (n:nat) (k:nat{n < k}) : Lemma (binomial n k = 0)
let rec binomial_lt n k =
match n, k with
| _, 0 -> ()
| 0, _ -> ()
| _ -> binomial_lt (n - 1) k; binomial_lt (n - 1) (k - 1)
val binomial_n (n:nat) : Lemma (binomial n n == 1)
let rec binomial_n n =
match n with
| 0 -> ()
| _ -> binomial_lt n (n + 1); binomial_n (n - 1)
val pascal (n:nat) (k:pos{k <= n}) : Lemma
(binomial n k + binomial n (k - 1) = binomial (n + 1) k)
let pascal n k = ()
val factorial: nat -> pos
let rec factorial = function
| 0 -> 1
| n -> n * factorial (n - 1)
let ( ! ) n = factorial n | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Euclid.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Fermat.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Euclid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m: Prims.nat -> n: Prims.nat
-> FStar.Pervasives.Lemma (ensures FStar.Math.Fermat.binomial (n + m) n * (!n * !m) == !(n + m)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"Prims.int",
"FStar.Math.Fermat.binomial_n",
"FStar.Pervasives.Native.tuple2",
"FStar.Calc.calc_finish",
"Prims.eq2",
"FStar.Mul.op_Star",
"FStar.Math.Fermat.binomial",
"Prims.op_Addition",
"FStar.Math.Fermat.op_Bang",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Prims.op_Subtraction",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Fermat.pascal",
"Prims.squash",
"FStar.Math.Lemmas.addition_is_associative",
"Prims.op_Minus",
"FStar.Math.Lemmas.distributivity_add_left",
"FStar.Math.Fermat.binomial_factorial",
"Prims.l_True",
"Prims.op_Multiply",
"FStar.Pervasives.pattern",
"FStar.Tactics.Effect.assert_by_tactic",
"FStar.Tactics.CanonCommSemiring.int_semiring"
] | [
"recursion"
] | false | false | true | false | false | let rec binomial_factorial m n =
| match m, n with
| 0, _ -> binomial_n n
| _, 0 -> ()
| _ ->
let open FStar.Math.Lemmas in
let reorder1 (a b c d: int) : Lemma (a * (b * (c * d)) == c * (a * (b * d))) =
FStar.Tactics.Effect.assert_by_tactic (a * (b * (c * d)) == c * (a * (b * d)))
(fun _ ->
();
(FStar.Tactics.CanonCommSemiring.int_semiring ()))
in
let reorder2 (a b c d: int) : Lemma (a * ((b * c) * d) == b * (a * (c * d))) =
FStar.Tactics.Effect.assert_by_tactic (a * ((b * c) * d) == b * (a * (c * d)))
(fun _ ->
();
(FStar.Tactics.CanonCommSemiring.int_semiring ()))
in
calc ( == ) {
binomial (n + m) n * (!n * !m);
( == ) { pascal (n + m - 1) n }
(binomial (n + m - 1) n + binomial (n + m - 1) (n - 1)) * (!n * !m);
( == ) { addition_is_associative n m (- 1) }
(binomial (n + (m - 1)) n + binomial (n + (m - 1)) (n - 1)) * (!n * !m);
( == ) { distributivity_add_left (binomial (n + (m - 1)) n)
(binomial (n + (m - 1)) (n - 1))
(!n * !m) }
binomial (n + (m - 1)) n * (!n * !m) + binomial (n + (m - 1)) (n - 1) * (!n * !m);
( == ) { () }
binomial (n + (m - 1)) n * (!n * (m * !(m - 1))) +
binomial ((n - 1) + m) (n - 1) * ((n * !(n - 1)) * !m);
( == ) { (reorder1 (binomial (n + (m - 1)) n) (!n) m (!(m - 1));
reorder2 (binomial ((n - 1) + m) (n - 1)) n (!(n - 1)) (!m)) }
m * (binomial (n + (m - 1)) n * (!n * !(m - 1))) +
n * (binomial ((n - 1) + m) (n - 1) * (!(n - 1) * !m));
( == ) { (binomial_factorial (m - 1) n;
binomial_factorial m (n - 1)) }
m * !(n + (m - 1)) + n * !((n - 1) + m);
( == ) { () }
m * !(n + m - 1) + n * !(n + m - 1);
( == ) { () }
n * !(n + m - 1) + m * !(n + m - 1);
( == ) { distributivity_add_left m n (!(n + m - 1)) }
(n + m) * !(n + m - 1);
( == ) { () }
!(n + m);
} | false |
Hacl.Impl.Poly1305.fst | Hacl.Impl.Poly1305.poly1305_update_128_256 | val poly1305_update_128_256: #s:field_spec { s = M128 || s = M256 } -> poly1305_update_st s | val poly1305_update_128_256: #s:field_spec { s = M128 || s = M256 } -> poly1305_update_st s | let poly1305_update_128_256 #s ctx len text =
let pre = get_precomp_r ctx in
let acc = get_acc ctx in
let h0 = ST.get () in
poly1305_update_vec #s len text pre acc;
let h1 = ST.get () in
Equiv.poly1305_update_vec_lemma #(width s) (as_seq h0 text) (feval h0 acc).[0] (feval h0 (gsub pre 0ul 5ul)).[0] | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 114,
"end_line": 576,
"start_col": 0,
"start_line": 570
} | module Hacl.Impl.Poly1305
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Fields
open Hacl.Impl.Poly1305.Bignum128
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module S = Spec.Poly1305
module Vec = Hacl.Spec.Poly1305.Vec
module Equiv = Hacl.Spec.Poly1305.Equiv
module F32xN = Hacl.Impl.Poly1305.Field32xN
friend Lib.LoopCombinators
let _: squash (inversion field_spec) = allow_inversion field_spec
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let get_acc #s (ctx:poly1305_ctx s) : Stack (felem s)
(requires fun h -> live h ctx)
(ensures fun h0 acc h1 -> h0 == h1 /\ live h1 acc /\ acc == gsub ctx 0ul (nlimb s))
= sub ctx 0ul (nlimb s)
inline_for_extraction noextract
let get_precomp_r #s (ctx:poly1305_ctx s) : Stack (precomp_r s)
(requires fun h -> live h ctx)
(ensures fun h0 pre h1 -> h0 == h1 /\ live h1 pre /\ pre == gsub ctx (nlimb s) (precomplen s))
= sub ctx (nlimb s) (precomplen s)
unfold
let op_String_Access #a #len = LSeq.index #a #len
let as_get_acc #s h ctx = (feval h (gsub ctx 0ul (nlimb s))).[0]
let as_get_r #s h ctx = (feval h (gsub ctx (nlimb s) (nlimb s))).[0]
let state_inv_t #s h ctx =
felem_fits h (gsub ctx 0ul (nlimb s)) (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h (gsub ctx (nlimb s) (precomplen s))
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --record_options"
let reveal_ctx_inv' #s ctx ctx' h0 h1 =
let acc_b = gsub ctx 0ul (nlimb s) in
let acc_b' = gsub ctx' 0ul (nlimb s) in
let r_b = gsub ctx (nlimb s) (nlimb s) in
let r_b' = gsub ctx' (nlimb s) (nlimb s) in
let precom_b = gsub ctx (nlimb s) (precomplen s) in
let precom_b' = gsub ctx' (nlimb s) (precomplen s) in
as_seq_gsub h0 ctx 0ul (nlimb s);
as_seq_gsub h1 ctx 0ul (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (nlimb s);
as_seq_gsub h1 ctx (nlimb s) (nlimb s);
as_seq_gsub h0 ctx (nlimb s) (precomplen s);
as_seq_gsub h1 ctx (nlimb s) (precomplen s);
as_seq_gsub h0 ctx' 0ul (nlimb s);
as_seq_gsub h1 ctx' 0ul (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (nlimb s);
as_seq_gsub h1 ctx' (nlimb s) (nlimb s);
as_seq_gsub h0 ctx' (nlimb s) (precomplen s);
as_seq_gsub h1 ctx' (nlimb s) (precomplen s);
assert (as_seq h0 acc_b == as_seq h1 acc_b');
assert (as_seq h0 r_b == as_seq h1 r_b');
assert (as_seq h0 precom_b == as_seq h1 precom_b')
val fmul_precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.fmul_precomp_r_pre #(width s) h precomp_b)
let fmul_precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let r_b5 = gsub precomp_b (nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (nlimb s) (nlimb s);
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h r_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h r_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h r_b))
val precomp_inv_zeros: #s:field_spec -> precomp_b:lbuffer (limb s) (precomplen s) -> h:mem ->
Lemma
(requires as_seq h precomp_b == Lib.Sequence.create (v (precomplen s)) (limb_zero s))
(ensures F32xN.load_precompute_r_post #(width s) h precomp_b)
#push-options "--z3rlimit 150"
let precomp_inv_zeros #s precomp_b h =
let r_b = gsub precomp_b 0ul (nlimb s) in
let rn_b = gsub precomp_b (2ul *! nlimb s) (nlimb s) in
let rn_b5 = gsub precomp_b (3ul *! nlimb s) (nlimb s) in
as_seq_gsub h precomp_b 0ul (nlimb s);
as_seq_gsub h precomp_b (2ul *! nlimb s) (nlimb s);
as_seq_gsub h precomp_b (3ul *! nlimb s) (nlimb s);
fmul_precomp_inv_zeros #s precomp_b h;
Hacl.Spec.Poly1305.Field32xN.Lemmas.precomp_r5_zeros (width s);
LSeq.eq_intro (feval h r_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b) (LSeq.create (width s) 0);
LSeq.eq_intro (feval h rn_b5) (LSeq.create (width s) 0);
assert (F32xN.as_tup5 #(width s) h rn_b5 == F32xN.precomp_r5 (F32xN.as_tup5 h rn_b));
assert (feval h rn_b == Vec.compute_rw (feval h r_b).[0])
#pop-options
let ctx_inv_zeros #s ctx h =
// ctx = [acc_b; r_b; r_b5; rn_b; rn_b5]
let acc_b = gsub ctx 0ul (nlimb s) in
as_seq_gsub h ctx 0ul (nlimb s);
LSeq.eq_intro (feval h acc_b) (LSeq.create (width s) 0);
assert (felem_fits h acc_b (2, 2, 2, 2, 2));
let precomp_b = gsub ctx (nlimb s) (precomplen s) in
LSeq.eq_intro (as_seq h precomp_b) (Lib.Sequence.create (v (precomplen s)) (limb_zero s));
precomp_inv_zeros #s precomp_b h
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
val poly1305_encode_block:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode 16 (as_seq h0 b))
let poly1305_encode_block #s f b =
load_felem_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_blocks:
#s:field_spec
-> f:felem s
-> b:lbuffer uint8 (blocklen s) ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
feval h1 f == Vec.load_blocks #(width s) (as_seq h0 b))
let poly1305_encode_blocks #s f b =
load_felems_le f b;
set_bit128 f
inline_for_extraction noextract
val poly1305_encode_last:
#s:field_spec
-> f:felem s
-> len:size_t{v len < 16}
-> b:lbuffer uint8 len ->
Stack unit
(requires fun h ->
live h b /\ live h f /\ disjoint b f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(feval h1 f).[0] == S.encode (v len) (as_seq h0 b))
let poly1305_encode_last #s f len b =
push_frame();
let tmp = create 16ul (u8 0) in
update_sub tmp 0ul len b;
let h0 = ST.get () in
Hacl.Impl.Poly1305.Lemmas.nat_from_bytes_le_eq_lemma (v len) (as_seq h0 b);
assert (BSeq.nat_from_bytes_le (as_seq h0 b) == BSeq.nat_from_bytes_le (as_seq h0 tmp));
assert (BSeq.nat_from_bytes_le (as_seq h0 b) < pow2 (v len * 8));
load_felem_le f tmp;
let h1 = ST.get () in
lemma_feval_is_fas_nat h1 f;
set_bit f (len *! 8ul);
pop_frame()
inline_for_extraction noextract
val poly1305_encode_r:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h b /\ live h p /\ disjoint b p)
(ensures fun h0 _ h1 ->
modifies (loc p) h0 h1 /\
F32xN.load_precompute_r_post #(width s) h1 p /\
(feval h1 (gsub p 0ul 5ul)).[0] == S.poly1305_encode_r (as_seq h0 b))
let poly1305_encode_r #s p b =
let lo = uint_from_bytes_le (sub b 0ul 8ul) in
let hi = uint_from_bytes_le (sub b 8ul 8ul) in
let mask0 = u64 0x0ffffffc0fffffff in
let mask1 = u64 0x0ffffffc0ffffffc in
let lo = lo &. mask0 in
let hi = hi &. mask1 in
load_precompute_r p lo hi
[@ Meta.Attribute.specialize ]
let poly1305_init #s ctx key =
let acc = get_acc ctx in
let pre = get_precomp_r ctx in
let kr = sub key 0ul 16ul in
set_zero acc;
poly1305_encode_r #s pre kr
inline_for_extraction noextract
val update1:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 16ul
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h b /\ live h acc /\
disjoint p acc /\ disjoint b acc /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] == S.poly1305_update1
(feval h0 (gsub p 0ul 5ul)).[0] 16 (as_seq h0 b) (feval h0 acc).[0])
let update1 #s pre b acc =
push_frame ();
let e = create (nlimb s) (limb_zero s) in
poly1305_encode_block e b;
fadd_mul_r acc e pre;
pop_frame ()
let poly1305_update1 #s ctx text =
let pre = get_precomp_r ctx in
let acc = get_acc ctx in
update1 pre text acc
inline_for_extraction noextract
val poly1305_update_last:
#s:field_spec
-> p:precomp_r s
-> len:size_t{v len < 16}
-> b:lbuffer uint8 len
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h b /\ live h acc /\
disjoint p acc /\ disjoint b acc /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] == S.poly1305_update1
(feval h0 (gsub p 0ul 5ul)).[0] (v len) (as_seq h0 b) (feval h0 acc).[0])
#push-options "--z3rlimit 200"
let poly1305_update_last #s pre len b acc =
push_frame ();
let e = create (nlimb s) (limb_zero s) in
poly1305_encode_last e len b;
fadd_mul_r acc e pre;
pop_frame ()
#pop-options
inline_for_extraction noextract
val poly1305_update_nblocks:
#s:field_spec
-> p:precomp_r s
-> b:lbuffer uint8 (blocklen s)
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h b /\ live h acc /\
disjoint acc p /\ disjoint acc b /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
feval h1 acc ==
Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub p 10ul 5ul)) (as_seq h0 b) (feval h0 acc))
let poly1305_update_nblocks #s pre b acc =
push_frame ();
let e = create (nlimb s) (limb_zero s) in
poly1305_encode_blocks e b;
fmul_rn acc acc pre;
fadd acc acc e;
pop_frame ()
inline_for_extraction noextract
val poly1305_update1_f:
#s:field_spec
-> p:precomp_r s
-> nb:size_t
-> len:size_t{v nb == v len / 16}
-> text:lbuffer uint8 len
-> i:size_t{v i < v nb}
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h text /\ live h acc /\
disjoint acc p /\ disjoint acc text /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
LSeq.repeat_blocks_f #uint8 #S.felem 16
(as_seq h0 text) (S.poly1305_update1 (feval h0 (gsub p 0ul 5ul)).[0] 16) (v nb) (v i) (feval h0 acc).[0])
let poly1305_update1_f #s pre nb len text i acc=
assert ((v i + 1) * 16 <= v nb * 16);
let block = sub #_ #_ #len text (i *! 16ul) 16ul in
update1 #s pre block acc
#push-options "--z3rlimit 100 --max_fuel 1"
inline_for_extraction noextract
val poly1305_update_scalar:
#s:field_spec
-> len:size_t
-> text:lbuffer uint8 len
-> pre:precomp_r s
-> acc:felem s ->
Stack unit
(requires fun h ->
live h text /\ live h acc /\ live h pre /\
disjoint acc text /\ disjoint acc pre /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h pre)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
S.poly1305_update (as_seq h0 text) (feval h0 acc).[0] (feval h0 (gsub pre 0ul 5ul)).[0])
let poly1305_update_scalar #s len text pre acc =
let nb = len /. 16ul in
let rem = len %. 16ul in
let h0 = ST.get () in
LSeq.lemma_repeat_blocks #uint8 #S.felem 16 (as_seq h0 text)
(S.poly1305_update1 (feval h0 (gsub pre 0ul 5ul)).[0] 16)
(S.poly1305_update_last (feval h0 (gsub pre 0ul 5ul)).[0])
(feval h0 acc).[0];
[@ inline_let]
let spec_fh h0 =
LSeq.repeat_blocks_f 16 (as_seq h0 text)
(S.poly1305_update1 (feval h0 (gsub pre 0ul 5ul)).[0] 16) (v nb) in
[@ inline_let]
let inv h (i:nat{i <= v nb}) =
modifies1 acc h0 h /\
live h pre /\ live h text /\ live h acc /\
disjoint acc pre /\ disjoint acc text /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.fmul_precomp_r_pre #(width s) h pre /\
(feval h acc).[0] == Lib.LoopCombinators.repeati i (spec_fh h0) (feval h0 acc).[0] in
Lib.Loops.for (size 0) nb inv
(fun i ->
Lib.LoopCombinators.unfold_repeati (v nb) (spec_fh h0) (feval h0 acc).[0] (v i);
poly1305_update1_f #s pre nb len text i acc);
let h1 = ST.get () in
assert ((feval h1 acc).[0] == Lib.LoopCombinators.repeati (v nb) (spec_fh h0) (feval h0 acc).[0]);
if rem >. 0ul then (
let last = sub text (nb *! 16ul) rem in
as_seq_gsub h1 text (nb *! 16ul) rem;
assert (disjoint acc last);
poly1305_update_last #s pre rem last acc)
#pop-options
inline_for_extraction noextract
val poly1305_update_multi_f:
#s:field_spec
-> p:precomp_r s
-> bs:size_t{v bs == width s * S.size_block}
-> nb:size_t
-> len:size_t{v nb == v len / v bs /\ v len % v bs == 0}
-> text:lbuffer uint8 len
-> i:size_t{v i < v nb}
-> acc:felem s ->
Stack unit
(requires fun h ->
live h p /\ live h text /\ live h acc /\
disjoint acc p /\ disjoint acc text /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h1 p /\
feval h1 acc ==
LSeq.repeat_blocks_f #uint8 #(Vec.elem (width s))
(v bs) (as_seq h0 text) (Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub p 10ul 5ul))) (v nb) (v i) (feval h0 acc))
let poly1305_update_multi_f #s pre bs nb len text i acc=
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub #_ #_ #len text (i *! bs) bs in
let h1 = ST.get () in
as_seq_gsub h1 text (i *! bs) bs;
poly1305_update_nblocks #s pre block acc
#push-options "--max_fuel 1"
inline_for_extraction noextract
val poly1305_update_multi_loop:
#s:field_spec
-> bs:size_t{v bs == width s * S.size_block}
-> len:size_t{v len % v (blocklen s) == 0}
-> text:lbuffer uint8 len
-> pre:precomp_r s
-> acc:felem s ->
Stack unit
(requires fun h ->
live h pre /\ live h acc /\ live h text /\
disjoint acc text /\ disjoint acc pre /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h pre)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h1 pre /\
feval h1 acc == LSeq.repeat_blocks_multi #uint8 #(Vec.elem (width s)) (v bs) (as_seq h0 text)
(Vec.poly1305_update_nblocks (feval h0 (gsub pre 10ul 5ul))) (feval h0 acc))
let poly1305_update_multi_loop #s bs len text pre acc =
let nb = len /. bs in
let h0 = ST.get () in
LSeq.lemma_repeat_blocks_multi #uint8 #(Vec.elem (width s)) (v bs) (as_seq h0 text)
(Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub pre 10ul 5ul))) (feval h0 acc);
[@ inline_let]
let spec_fh h0 =
LSeq.repeat_blocks_f (v bs) (as_seq h0 text)
(Vec.poly1305_update_nblocks #(width s) (feval h0 (gsub pre 10ul 5ul))) (v nb) in
[@ inline_let]
let inv h (i:nat{i <= v nb}) =
modifies1 acc h0 h /\
live h pre /\ live h text /\ live h acc /\
disjoint acc pre /\ disjoint acc text /\
felem_fits h acc (3, 3, 3, 3, 3) /\
F32xN.load_precompute_r_post #(width s) h pre /\
feval h acc == Lib.LoopCombinators.repeati i (spec_fh h0) (feval h0 acc) in
Lib.Loops.for (size 0) nb inv
(fun i ->
Lib.LoopCombinators.unfold_repeati (v nb) (spec_fh h0) (feval h0 acc) (v i);
poly1305_update_multi_f #s pre bs nb len text i acc)
#pop-options
#push-options "--z3rlimit 350"
inline_for_extraction noextract
val poly1305_update_multi:
#s:field_spec
-> len:size_t{0 < v len /\ v len % v (blocklen s) == 0}
-> text:lbuffer uint8 len
-> pre:precomp_r s
-> acc:felem s ->
Stack unit
(requires fun h ->
live h pre /\ live h acc /\ live h text /\
disjoint acc text /\ disjoint acc pre /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h pre)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
Vec.poly1305_update_multi #(width s) (as_seq h0 text)
(feval h0 acc).[0] (feval h0 (gsub pre 0ul 5ul)).[0])
let poly1305_update_multi #s len text pre acc =
let h0 = ST.get () in
assert_norm (v 10ul + v 5ul <= v 20ul);
assert (feval h0 (gsub pre 10ul 5ul) == Vec.compute_rw #(width s) ((feval h0 (gsub pre 0ul 5ul)).[0]));
let bs = blocklen s in
//assert (v bs == width s * S.size_block);
let text0 = sub text 0ul bs in
load_acc #s acc text0;
let len1 = len -! bs in
let text1 = sub text bs len1 in
poly1305_update_multi_loop #s bs len1 text1 pre acc;
fmul_rn_normalize acc pre
#pop-options
inline_for_extraction noextract
val poly1305_update_vec:
#s:field_spec
-> len:size_t
-> text:lbuffer uint8 len
-> pre:precomp_r s
-> acc:felem s ->
Stack unit
(requires fun h ->
live h text /\ live h acc /\ live h pre /\
disjoint acc text /\ disjoint acc pre /\
felem_fits h acc (2, 2, 2, 2, 2) /\
F32xN.load_precompute_r_post #(width s) h pre)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (2, 2, 2, 2, 2) /\
(feval h1 acc).[0] ==
Vec.poly1305_update_vec #(width s) (as_seq h0 text) (feval h0 acc).[0] (feval h0 (gsub pre 0ul 5ul)).[0])
let poly1305_update_vec #s len text pre acc =
let sz_block = blocklen s in
FStar.Math.Lemmas.multiply_fractions (v len) (v sz_block);
let len0 = (len /. sz_block) *! sz_block in
let t0 = sub text 0ul len0 in
FStar.Math.Lemmas.multiple_modulo_lemma (v (len /. sz_block)) (v (blocklen s));
if len0 >. 0ul then poly1305_update_multi len0 t0 pre acc;
let len1 = len -! len0 in
let t1 = sub text len0 len1 in
poly1305_update_scalar #s len1 t1 pre acc
inline_for_extraction noextract
val poly1305_update32: poly1305_update_st M32
let poly1305_update32 ctx len text =
let pre = get_precomp_r ctx in
let acc = get_acc ctx in
poly1305_update_scalar #M32 len text pre acc
inline_for_extraction noextract | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Equiv.fst.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Bignum128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": "F32xN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Equiv",
"short_module": "Equiv"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Bignum128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Hacl.Impl.Poly1305.poly1305_update_st s | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"Prims.b2t",
"Prims.op_BarBar",
"Prims.op_Equality",
"Hacl.Impl.Poly1305.Fields.M128",
"Hacl.Impl.Poly1305.Fields.M256",
"Hacl.Impl.Poly1305.poly1305_ctx",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Hacl.Spec.Poly1305.Equiv.poly1305_update_vec_lemma",
"Hacl.Impl.Poly1305.Fields.width",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Impl.Poly1305.op_String_Access",
"Spec.Poly1305.felem",
"Hacl.Impl.Poly1305.Fields.feval",
"Lib.Buffer.gsub",
"Hacl.Impl.Poly1305.Fields.limb",
"Hacl.Impl.Poly1305.Fields.precomplen",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.Poly1305.poly1305_update_vec",
"Hacl.Impl.Poly1305.Fields.felem",
"Hacl.Impl.Poly1305.get_acc",
"Hacl.Impl.Poly1305.Fields.precomp_r",
"Hacl.Impl.Poly1305.get_precomp_r"
] | [] | false | false | false | false | false | let poly1305_update_128_256 #s ctx len text =
| let pre = get_precomp_r ctx in
let acc = get_acc ctx in
let h0 = ST.get () in
poly1305_update_vec #s len text pre acc;
let h1 = ST.get () in
Equiv.poly1305_update_vec_lemma #(width s)
(as_seq h0 text)
(feval h0 acc).[ 0 ]
(feval h0 (gsub pre 0ul 5ul)).[ 0 ] | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_code_Vslw | val va_code_Vslw : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr ->
Tot va_code | val va_code_Vslw : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr ->
Tot va_code | let va_code_Vslw dst src1 src2 =
(Ins (S.Vslw dst src1 src2)) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 30,
"end_line": 249,
"start_col": 0,
"start_line": 248
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld
[@ "opaque_to_smt"]
let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrld dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrld va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrld) (va_code_Mfvsrld dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrld dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrld dst src)) va_s0 in
Vale.Arch.Types.lo64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrld dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrld (va_code_Mfvsrld 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrdd
[@ "opaque_to_smt"]
let va_code_Mtvsrdd dst src1 src2 =
(Ins (S.Mtvsrdd dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrdd dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrdd va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Mtvsrdd) (va_code_Mtvsrdd dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrdd dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrdd dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrdd dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrdd (va_code_Mtvsrdd 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrws
[@ "opaque_to_smt"]
let va_code_Mtvsrws dst src =
(Ins (S.Mtvsrws dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrws dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrws va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mtvsrws) (va_code_Mtvsrws dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrws dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrws dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrws dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrws (va_code_Mtvsrws 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vadduwm
[@ "opaque_to_smt"]
let va_code_Vadduwm dst src1 src2 =
(Ins (S.Vadduwm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vadduwm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vadduwm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vadduwm) (va_code_Vadduwm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vadduwm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vadduwm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vadduwm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vadduwm (va_code_Vadduwm 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vxor
[@ "opaque_to_smt"]
let va_code_Vxor dst src1 src2 =
(Ins (S.Vxor dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vxor dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vxor va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vxor) (va_code_Vxor dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vxor dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vxor dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vxor dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vxor (va_code_Vxor 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vand
[@ "opaque_to_smt"]
let va_code_Vand dst src1 src2 =
(Ins (S.Vand dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vand dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vand va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vand) (va_code_Vand dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vand dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vand dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vand dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vand (va_code_Vand 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vslw | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src1: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src2: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Machine_s.Ins",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.Semantics_s.Vslw",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_Vslw dst src1 src2 =
| (Ins (S.Vslw dst src1 src2)) | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_code_Vsrw | val va_code_Vsrw : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr ->
Tot va_code | val va_code_Vsrw : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr ->
Tot va_code | let va_code_Vsrw dst src1 src2 =
(Ins (S.Vsrw dst src1 src2)) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 30,
"end_line": 278,
"start_col": 0,
"start_line": 277
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld
[@ "opaque_to_smt"]
let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrld dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrld va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrld) (va_code_Mfvsrld dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrld dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrld dst src)) va_s0 in
Vale.Arch.Types.lo64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrld dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrld (va_code_Mfvsrld 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrdd
[@ "opaque_to_smt"]
let va_code_Mtvsrdd dst src1 src2 =
(Ins (S.Mtvsrdd dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrdd dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrdd va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Mtvsrdd) (va_code_Mtvsrdd dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrdd dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrdd dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrdd dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrdd (va_code_Mtvsrdd 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrws
[@ "opaque_to_smt"]
let va_code_Mtvsrws dst src =
(Ins (S.Mtvsrws dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrws dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrws va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mtvsrws) (va_code_Mtvsrws dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrws dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrws dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrws dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrws (va_code_Mtvsrws 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vadduwm
[@ "opaque_to_smt"]
let va_code_Vadduwm dst src1 src2 =
(Ins (S.Vadduwm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vadduwm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vadduwm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vadduwm) (va_code_Vadduwm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vadduwm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vadduwm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vadduwm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vadduwm (va_code_Vadduwm 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vxor
[@ "opaque_to_smt"]
let va_code_Vxor dst src1 src2 =
(Ins (S.Vxor dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vxor dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vxor va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vxor) (va_code_Vxor dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vxor dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vxor dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vxor dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vxor (va_code_Vxor 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vand
[@ "opaque_to_smt"]
let va_code_Vand dst src1 src2 =
(Ins (S.Vand dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vand dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vand va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vand) (va_code_Vand dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vand dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vand dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vand dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vand (va_code_Vand 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vslw
[@ "opaque_to_smt"]
let va_code_Vslw dst src1 src2 =
(Ins (S.Vslw dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vslw dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vslw va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vslw) (va_code_Vslw dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vslw dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vslw dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vslw dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vslw (va_code_Vslw 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vsrw | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src1: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src2: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Machine_s.Ins",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.Semantics_s.Vsrw",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_Vsrw dst src1 src2 =
| (Ins (S.Vsrw dst src1 src2)) | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_codegen_success_Vsrw | val va_codegen_success_Vsrw : dst:va_operand_vec_opr -> src1:va_operand_vec_opr ->
src2:va_operand_vec_opr -> Tot va_pbool | val va_codegen_success_Vsrw : dst:va_operand_vec_opr -> src1:va_operand_vec_opr ->
src2:va_operand_vec_opr -> Tot va_pbool | let va_codegen_success_Vsrw dst src1 src2 =
(va_ttrue ()) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 282,
"start_col": 0,
"start_line": 281
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld
[@ "opaque_to_smt"]
let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrld dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrld va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrld) (va_code_Mfvsrld dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrld dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrld dst src)) va_s0 in
Vale.Arch.Types.lo64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrld dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrld (va_code_Mfvsrld 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrdd
[@ "opaque_to_smt"]
let va_code_Mtvsrdd dst src1 src2 =
(Ins (S.Mtvsrdd dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrdd dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrdd va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Mtvsrdd) (va_code_Mtvsrdd dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrdd dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrdd dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrdd dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrdd (va_code_Mtvsrdd 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrws
[@ "opaque_to_smt"]
let va_code_Mtvsrws dst src =
(Ins (S.Mtvsrws dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrws dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrws va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mtvsrws) (va_code_Mtvsrws dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrws dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrws dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrws dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrws (va_code_Mtvsrws 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vadduwm
[@ "opaque_to_smt"]
let va_code_Vadduwm dst src1 src2 =
(Ins (S.Vadduwm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vadduwm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vadduwm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vadduwm) (va_code_Vadduwm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vadduwm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vadduwm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vadduwm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vadduwm (va_code_Vadduwm 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vxor
[@ "opaque_to_smt"]
let va_code_Vxor dst src1 src2 =
(Ins (S.Vxor dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vxor dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vxor va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vxor) (va_code_Vxor dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vxor dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vxor dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vxor dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vxor (va_code_Vxor 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vand
[@ "opaque_to_smt"]
let va_code_Vand dst src1 src2 =
(Ins (S.Vand dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vand dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vand va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vand) (va_code_Vand dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vand dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vand dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vand dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vand (va_code_Vand 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vslw
[@ "opaque_to_smt"]
let va_code_Vslw dst src1 src2 =
(Ins (S.Vslw dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vslw dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vslw va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vslw) (va_code_Vslw dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vslw dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vslw dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vslw dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vslw (va_code_Vslw 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vsrw
[@ "opaque_to_smt"]
let va_code_Vsrw dst src1 src2 =
(Ins (S.Vsrw dst src1 src2)) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src1: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src2: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_Vsrw dst src1 src2 =
| (va_ttrue ()) | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_codegen_success_Vsl | val va_codegen_success_Vsl : dst:va_operand_vec_opr -> src1:va_operand_vec_opr ->
src2:va_operand_vec_opr -> Tot va_pbool | val va_codegen_success_Vsl : dst:va_operand_vec_opr -> src1:va_operand_vec_opr ->
src2:va_operand_vec_opr -> Tot va_pbool | let va_codegen_success_Vsl dst src1 src2 =
(va_ttrue ()) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 311,
"start_col": 0,
"start_line": 310
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrd
[@ "opaque_to_smt"]
let va_code_Mfvsrd dst src =
(Ins (S.Mfvsrd dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrd dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrd va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrd) (va_code_Mfvsrd dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrd dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrd dst src)) va_s0 in
Vale.Arch.Types.hi64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrd dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrd (va_code_Mfvsrd 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mfvsrld
[@ "opaque_to_smt"]
let va_code_Mfvsrld dst src =
(Ins (S.Mfvsrld dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mfvsrld dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mfvsrld va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mfvsrld) (va_code_Mfvsrld dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mfvsrld dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mfvsrld dst src)) va_s0 in
Vale.Arch.Types.lo64_reveal ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mfvsrld dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mfvsrld (va_code_Mfvsrld 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_reg_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrdd
[@ "opaque_to_smt"]
let va_code_Mtvsrdd dst src1 src2 =
(Ins (S.Mtvsrdd dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrdd dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrdd va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Mtvsrdd) (va_code_Mtvsrdd dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrdd dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrdd dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrdd dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrdd (va_code_Mtvsrdd 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mtvsrws
[@ "opaque_to_smt"]
let va_code_Mtvsrws dst src =
(Ins (S.Mtvsrws dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mtvsrws dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mtvsrws va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mtvsrws) (va_code_Mtvsrws dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Mtvsrws dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Mtvsrws dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mtvsrws dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mtvsrws (va_code_Mtvsrws 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vadduwm
[@ "opaque_to_smt"]
let va_code_Vadduwm dst src1 src2 =
(Ins (S.Vadduwm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vadduwm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vadduwm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vadduwm) (va_code_Vadduwm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vadduwm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vadduwm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vadduwm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vadduwm (va_code_Vadduwm 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vxor
[@ "opaque_to_smt"]
let va_code_Vxor dst src1 src2 =
(Ins (S.Vxor dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vxor dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vxor va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vxor) (va_code_Vxor dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vxor dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vxor dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vxor dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vxor (va_code_Vxor 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vand
[@ "opaque_to_smt"]
let va_code_Vand dst src1 src2 =
(Ins (S.Vand dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vand dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vand va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vand) (va_code_Vand dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vand dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vand dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vand dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vand (va_code_Vand 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vslw
[@ "opaque_to_smt"]
let va_code_Vslw dst src1 src2 =
(Ins (S.Vslw dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vslw dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vslw va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vslw) (va_code_Vslw dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vslw dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vslw dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vslw dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vslw (va_code_Vslw 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vsrw
[@ "opaque_to_smt"]
let va_code_Vsrw dst src1 src2 =
(Ins (S.Vsrw dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Vsrw dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vsrw va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Vsrw) (va_code_Vsrw dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vsrw dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vsrw dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Vsrw dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vsrw (va_code_Vsrw 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Vsl
[@ "opaque_to_smt"]
let va_code_Vsl dst src1 src2 =
(Ins (S.Vsl dst src1 src2)) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src1: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src2: Vale.PPC64LE.Decls.va_operand_vec_opr
-> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_Vsl dst src1 src2 =
| (va_ttrue ()) | false |
Vale.PPC64LE.InsVector.fst | Vale.PPC64LE.InsVector.va_wpProof_Vmr | val va_wpProof_Vmr : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Vmr dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Vmr dst src) ([va_mod_vec_opr dst])
va_s0 va_k ((va_sM, va_f0, va_g)))) | val va_wpProof_Vmr : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Vmr dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Vmr dst src) ([va_mod_vec_opr dst])
va_s0 va_k ((va_sM, va_f0, va_g)))) | let va_wpProof_Vmr dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"file_name": "obj/Vale.PPC64LE.InsVector.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 37,
"start_col": 0,
"start_line": 31
} | module Vale.PPC64LE.InsVector
open Vale.Def.Types_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Spec.Hash.Definitions
open Spec.SHA2
friend Vale.PPC64LE.Decls
module S = Vale.PPC64LE.Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50"
//-- Vmr
[@ "opaque_to_smt"]
let va_code_Vmr dst src =
(Ins (S.Vmr dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Vmr dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Vmr va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Vmr) (va_code_Vmr dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Vmr dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Vmr dst src)) va_s0 in
(va_sM, va_fM) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory_Sems.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.PPC64LE.Decls.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.InsVector.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.PPC64LE.Decls.va_operand_vec_opr ->
src: Vale.PPC64LE.Decls.va_operand_vec_opr ->
va_s0: Vale.PPC64LE.Decls.va_state ->
va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) * Prims.unit) | Prims.Ghost | [] | [] | [
"Vale.PPC64LE.Decls.va_operand_vec_opr",
"Vale.PPC64LE.Decls.va_state",
"Prims.unit",
"Vale.PPC64LE.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.PPC64LE.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.va_mod_vec_opr",
"Prims.Nil",
"Prims._assert",
"Vale.PPC64LE.Decls.va_state_eq",
"Vale.PPC64LE.Decls.va_update_ok",
"Vale.PPC64LE.Decls.va_update_operand_vec_opr",
"Vale.PPC64LE.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.InsVector.va_lemma_Vmr",
"Vale.PPC64LE.InsVector.va_code_Vmr"
] | [] | false | false | false | false | false | let va_wpProof_Vmr dst src va_s0 va_k =
| let va_sM, va_f0 = va_lemma_Vmr (va_code_Vmr 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_vec_opr dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_vec_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | false |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.