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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Hacl.Spec.Karatsuba.Lemmas.fst | Hacl.Spec.Karatsuba.Lemmas.lemma_bn_halves | val lemma_bn_halves: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a:nat{a < pow2 (pbits * aLen)} ->
Lemma (let p = pow2 (aLen / 2 * pbits) in a / p < p /\ a % p < p /\ a == a / p * p + a % p) | val lemma_bn_halves: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a:nat{a < pow2 (pbits * aLen)} ->
Lemma (let p = pow2 (aLen / 2 * pbits) in a / p < p /\ a % p < p /\ a == a / p * p + a % p) | let lemma_bn_halves pbits aLen a = lemma_double_p pbits aLen | {
"file_name": "code/bignum/Hacl.Spec.Karatsuba.Lemmas.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 60,
"end_line": 42,
"start_col": 0,
"start_line": 42
} | module Hacl.Spec.Karatsuba.Lemmas
open FStar.Mul
open Lib.IntTypes
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
type sign =
| Positive
| Negative
let abs (a:nat) (b:nat) : nat =
if a < b then b - a else a - b
val sign_abs: a:nat -> b:nat ->
Pure (tuple2 sign nat)
(requires True)
(ensures fun (s, res) -> res == abs a b /\
s == (if a < b then Negative else Positive))
let sign_abs a b =
if a < b then (Negative, b - a) else (Positive, a - b)
val lemma_double_p: pbits:pos -> aLen:nat{aLen % 2 = 0} ->
Lemma (let p = pow2 (aLen / 2 * pbits) in p * p == pow2 (pbits * aLen))
let lemma_double_p pbits aLen =
let p = pow2 (aLen / 2 * pbits) in
calc (==) {
p * p;
(==) { Math.Lemmas.pow2_plus (aLen / 2 * pbits) (aLen / 2 * pbits) }
pow2 (aLen / 2 * pbits + aLen / 2 * pbits);
(==) { Math.Lemmas.distributivity_add_left (aLen / 2) (aLen / 2) pbits }
pow2 ((aLen / 2 * 2) * pbits);
(==) { Math.Lemmas.lemma_div_exact aLen 2 }
pow2 (aLen * pbits);
}
val lemma_bn_halves: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a:nat{a < pow2 (pbits * aLen)} -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Karatsuba.Lemmas.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Karatsuba",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Karatsuba",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | pbits: Prims.pos -> aLen: Prims.nat{aLen % 2 = 0} -> a: Prims.nat{a < Prims.pow2 (pbits * aLen)}
-> FStar.Pervasives.Lemma
(ensures
(let p = Prims.pow2 ((aLen / 2) * pbits) in
a / p < p /\ a % p < p /\ a == (a / p) * p + a % p)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.pos",
"Prims.nat",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Mul.op_Star",
"Hacl.Spec.Karatsuba.Lemmas.lemma_double_p",
"Prims.unit"
] | [] | true | false | true | false | false | let lemma_bn_halves pbits aLen a =
| lemma_double_p pbits aLen | false |
Vale.AES.GCM_s.fst | Vale.AES.GCM_s.gcm_decrypt_LE | val gcm_decrypt_LE : alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
cipher: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
tag: FStar.Seq.Base.seq Vale.Def.Types_s.nat8
-> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat8 * Prims.bool) | let gcm_decrypt_LE = opaque_make gcm_decrypt_LE_def | {
"file_name": "vale/specs/crypto/Vale.AES.GCM_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 70,
"end_line": 95,
"start_col": 19,
"start_line": 95
} | module Vale.AES.GCM_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GHash_s
open FStar.Seq
open FStar.Mul
unfold type gcm_plain_LE = gctr_plain_LE
unfold type gcm_auth_LE = gctr_plain_LE
#reset-options "--z3rlimit 30"
type supported_iv_LE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 }
let compute_iv_BE_def (h_LE:quad32) (iv:supported_iv_LE) : quad32
=
if 8 * (length iv) = 96 then (
let iv_LE = le_bytes_to_quad32 (pad_to_128_bits iv) in
let iv_BE = reverse_bytes_quad32 iv_LE in
let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in
j0_BE
) else (
let padded_iv_quads = le_bytes_to_seq_quad32 (pad_to_128_bits iv) in
let length_BE = insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0 in
let length_LE = reverse_bytes_quad32 length_BE in
let hash_input_LE = append padded_iv_quads (create 1 length_LE) in
let hash_output_LE = ghash_LE h_LE hash_input_LE in
reverse_bytes_quad32 hash_output_LE
)
[@"opaque_to_smt"] let compute_iv_BE = opaque_make compute_iv_BE_def
irreducible let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def
// little-endian
let gcm_encrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (plain:seq nat8) (auth:seq nat8) :
Pure (seq nat8 & seq nat8)
(requires
is_aes_key alg key /\
length plain < pow2_32 /\
length auth < pow2_32
)
(ensures fun (c, t) -> True)
=
let key_LE = seq_nat8_to_seq_nat32_LE key in
let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_LE iv in
let c = gctr_encrypt_LE (inc32 j0_BE 1) plain alg key_LE in
// Sets the first 64-bit number to 8 * length plain, and the second to 8* length auth
let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0 in
let lengths_LE = reverse_bytes_quad32 lengths_BE in
let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits c) in
let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in
let s_LE = ghash_LE h_LE hash_input_LE in
let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in
(c, t)
[@"opaque_to_smt"] let gcm_encrypt_LE = opaque_make gcm_encrypt_LE_def
irreducible let gcm_encrypt_LE_reveal = opaque_revealer (`%gcm_encrypt_LE) gcm_encrypt_LE gcm_encrypt_LE_def
let gcm_decrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (cipher:seq nat8) (auth:seq nat8) (tag:seq nat8) :
Pure (seq nat8 & bool)
(requires
is_aes_key alg key /\
length cipher < pow2_32 /\
length auth < pow2_32
)
(ensures fun (p, t) -> True)
=
let key_LE = seq_nat8_to_seq_nat32_LE key in
let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_LE iv in
let p = gctr_encrypt_LE (inc32 j0_BE 1) cipher alg key_LE in // TODO: Rename gctr_encrypt_LE to gctr_LE
let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length cipher) 0 in
let lengths_LE = reverse_bytes_quad32 lengths_BE in
let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in
let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in
let s_LE = ghash_LE h_LE hash_input_LE in
let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GCM_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
cipher: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
tag: FStar.Seq.Base.seq Vale.Def.Types_s.nat8
-> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat8 * Prims.bool) | Prims.Pure | [] | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Pervasives.Native.tuple2",
"Prims.bool",
"Prims.l_and",
"Vale.AES.AES_common_s.is_aes_key",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Vale.Def.Words_s.pow2_32",
"Prims.l_True",
"Vale.AES.GCM_s.gcm_decrypt_LE_def"
] | [] | false | false | false | false | false | let gcm_decrypt_LE =
| opaque_make gcm_decrypt_LE_def | false |
|
Pulse.Lib.BoundedIntegers.fst | Pulse.Lib.BoundedIntegers.safe_mod | val safe_mod (#t: eqtype) {| c: bounded_unsigned t |} (x y: t)
: Pure (option t) (requires v y > 0) (ensures fun o -> Some? o ==> v (Some?.v o) == v x % v y) | val safe_mod (#t: eqtype) {| c: bounded_unsigned t |} (x y: t)
: Pure (option t) (requires v y > 0) (ensures fun o -> Some? o ==> v (Some?.v o) == v x % v y) | let safe_mod (#t:eqtype) {| c: bounded_unsigned t |} (x : t) (y : t)
: Pure (option t)
(requires v y > 0)
(ensures fun o -> Some? o ==> v (Some?.v o) == v x % v y)
= if c.static_max_bound
then Some (x % y)
else (
if y <= max_bound
then (
assert (fits #t (v x % v y));
Some (x % y)
)
else None
) | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.BoundedIntegers.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 5,
"end_line": 103,
"start_col": 0,
"start_line": 90
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.BoundedIntegers
module TC = FStar.Tactics.Typeclasses
let fits_t (fits:int -> prop) = x:int { fits x }
class bounded_int (t:eqtype) = {
fits: int -> prop;
v : t -> GTot int;
u : fits_t fits -> GTot t;
( + ) : (x:t -> y:t -> Pure t (requires fits (v x + v y)) (ensures fun z -> v z == v x + v y));
op_Subtraction : (x:t -> y:t -> Pure t (requires fits (v x - v y)) (ensures fun z -> v z == v x - v y));
( < ) : (x:t -> y:t -> b:bool { b = (v x < v y)});
( <= ) : (x:t -> y:t -> b:bool { b = (v x <= v y)});
( % ) : (x:t -> y:t -> Pure t (requires v y > 0 /\ fits (v x % v y)) (ensures fun z -> v z == v x % v y));
[@@@TC.no_method]
properties: squash (
(forall (x:t). {:pattern v x} fits (v x))
)
(* ...todo, add other ops **)
}
instance bounded_int_int : bounded_int int = {
fits = (fun _ -> True);
v = id;
u = id;
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y);
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
class bounded_unsigned (t:eqtype) = {
[@@@TC.no_method]
base:bounded_int t;
max_bound:t;
[@@@TC.no_method]
static_max_bound: bool;
[@@@TC.no_method]
properties: squash (
(forall (x:t). v x >= 0 /\ (static_max_bound ==> v x <= v max_bound)) /\
(forall (x:nat). x <= v max_bound ==> fits #t x)
)
}
instance bounded_from_bounded_unsigned (t:eqtype) (c:bounded_unsigned t) : bounded_int t = c.base
let safe_add (#t:eqtype) {| c: bounded_unsigned t |} (x y : t)
: o:option t { Some? o ==> v (Some?.v o) == v x + v y }
= if c.static_max_bound
then (
assert ( x <= max_bound);
if (y <= max_bound - x)
then Some (x + y)
else None
)
else (
if x <= max_bound
then (
assert (fits #t (v (max_bound #t) - v x));
if (y <= max_bound - x)
then Some (x + y)
else None
)
else None
) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Lib.BoundedIntegers.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": "TC"
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | {| c: Pulse.Lib.BoundedIntegers.bounded_unsigned t |} -> x: t -> y: t
-> Prims.Pure (FStar.Pervasives.Native.option t) | Prims.Pure | [] | [] | [
"Prims.eqtype",
"Pulse.Lib.BoundedIntegers.bounded_unsigned",
"Pulse.Lib.BoundedIntegers.__proj__Mkbounded_unsigned__item__static_max_bound",
"FStar.Pervasives.Native.Some",
"Pulse.Lib.BoundedIntegers.op_Percent",
"Pulse.Lib.BoundedIntegers.bounded_from_bounded_unsigned",
"Prims.bool",
"Pulse.Lib.BoundedIntegers.op_Less_Equals",
"Pulse.Lib.BoundedIntegers.max_bound",
"Prims.unit",
"Prims._assert",
"Pulse.Lib.BoundedIntegers.fits",
"Prims.int",
"Pulse.Lib.BoundedIntegers.bounded_int_int",
"Pulse.Lib.BoundedIntegers.v",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.l_imp",
"FStar.Pervasives.Native.uu___is_Some",
"Prims.eq2",
"FStar.Pervasives.Native.__proj__Some__item__v"
] | [] | false | false | false | false | false | let safe_mod (#t: eqtype) {| c: bounded_unsigned t |} (x y: t)
: Pure (option t) (requires v y > 0) (ensures fun o -> Some? o ==> v (Some?.v o) == v x % v y) =
| if c.static_max_bound
then Some (x % y)
else
(if y <= max_bound
then
(assert (fits #t (v x % v y));
Some (x % y))
else None) | false |
Pulse.Lib.BoundedIntegers.fst | Pulse.Lib.BoundedIntegers.add_nat_1 | val add_nat_1 : x: Prims.nat -> Prims.int | let add_nat_1 (x:nat) = x + 1 | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.BoundedIntegers.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 29,
"end_line": 162,
"start_col": 0,
"start_line": 162
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.BoundedIntegers
module TC = FStar.Tactics.Typeclasses
let fits_t (fits:int -> prop) = x:int { fits x }
class bounded_int (t:eqtype) = {
fits: int -> prop;
v : t -> GTot int;
u : fits_t fits -> GTot t;
( + ) : (x:t -> y:t -> Pure t (requires fits (v x + v y)) (ensures fun z -> v z == v x + v y));
op_Subtraction : (x:t -> y:t -> Pure t (requires fits (v x - v y)) (ensures fun z -> v z == v x - v y));
( < ) : (x:t -> y:t -> b:bool { b = (v x < v y)});
( <= ) : (x:t -> y:t -> b:bool { b = (v x <= v y)});
( % ) : (x:t -> y:t -> Pure t (requires v y > 0 /\ fits (v x % v y)) (ensures fun z -> v z == v x % v y));
[@@@TC.no_method]
properties: squash (
(forall (x:t). {:pattern v x} fits (v x))
)
(* ...todo, add other ops **)
}
instance bounded_int_int : bounded_int int = {
fits = (fun _ -> True);
v = id;
u = id;
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y);
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
class bounded_unsigned (t:eqtype) = {
[@@@TC.no_method]
base:bounded_int t;
max_bound:t;
[@@@TC.no_method]
static_max_bound: bool;
[@@@TC.no_method]
properties: squash (
(forall (x:t). v x >= 0 /\ (static_max_bound ==> v x <= v max_bound)) /\
(forall (x:nat). x <= v max_bound ==> fits #t x)
)
}
instance bounded_from_bounded_unsigned (t:eqtype) (c:bounded_unsigned t) : bounded_int t = c.base
let safe_add (#t:eqtype) {| c: bounded_unsigned t |} (x y : t)
: o:option t { Some? o ==> v (Some?.v o) == v x + v y }
= if c.static_max_bound
then (
assert ( x <= max_bound);
if (y <= max_bound - x)
then Some (x + y)
else None
)
else (
if x <= max_bound
then (
assert (fits #t (v (max_bound #t) - v x));
if (y <= max_bound - x)
then Some (x + y)
else None
)
else None
)
let safe_mod (#t:eqtype) {| c: bounded_unsigned t |} (x : t) (y : t)
: Pure (option t)
(requires v y > 0)
(ensures fun o -> Some? o ==> v (Some?.v o) == v x % v y)
= if c.static_max_bound
then Some (x % y)
else (
if y <= max_bound
then (
assert (fits #t (v x % v y));
Some (x % y)
)
else None
)
let ok (#t:eqtype) {| c:bounded_int t |} (op: int -> int -> int) (x y:t) =
c.fits (op (v x) (v y))
let add (#t:eqtype) {| bounded_int t |} (x:t) (y:t { ok (+) x y }) = x + y
let add3 (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) z (x + y)}) = x + y + z
//Writing the signature of bounded_int.(+) using Pure
//allows this to work, since the type of (x+y) is not refined
let add3_alt (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) (x + y) z}) = x + y + z
instance bounded_int_u32 : bounded_int FStar.UInt32.t = {
fits = (fun x -> 0 <= x /\ x < 4294967296);
v = (fun x -> FStar.UInt32.v x);
u = FStar.UInt32.uint_to_t;
( + ) = (fun x y -> FStar.UInt32.add x y);
op_Subtraction = (fun x y -> FStar.UInt32.sub x y);
( < ) = FStar.UInt32.(fun x y -> x <^ y);
( <= ) = FStar.UInt32.(fun x y -> x <=^ y);
( % ) = FStar.UInt32.(fun x y -> x %^ y);
properties = ()
}
instance bounded_unsigned_u32 : bounded_unsigned FStar.UInt32.t = {
base = TC.solve;
max_bound = 0xfffffffful;
static_max_bound = true;
properties = ()
}
instance bounded_int_u64 : bounded_int FStar.UInt64.t = {
fits = (fun x -> 0 <= x /\ x <= 0xffffffffffffffff);
v = (fun x -> FStar.UInt64.v x);
u = FStar.UInt64.uint_to_t;
( + ) = (fun x y -> FStar.UInt64.add x y);
op_Subtraction = (fun x y -> FStar.UInt64.sub x y);
( < ) = FStar.UInt64.(fun x y -> x <^ y);
( <= ) = FStar.UInt64.(fun x y -> x <=^ y);
( % ) = FStar.UInt64.(fun x y -> x %^ y);
properties = ()
}
instance bounded_unsigned_u64 : bounded_unsigned FStar.UInt64.t = {
base = TC.solve;
max_bound = 0xffffffffffffffffuL;
static_max_bound = true;
properties = ()
}
let test (t:eqtype) {| _ : bounded_unsigned t |} (x:t) = v x
let add_u32 (x:FStar.UInt32.t) (y:FStar.UInt32.t { ok (+) x y }) = x + y
//Again, parser doesn't allow using (-)
let sub_u32 (x:FStar.UInt32.t) (y:FStar.UInt32.t { ok op_Subtraction x y}) = x - y | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Lib.BoundedIntegers.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": "TC"
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.nat -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Pulse.Lib.BoundedIntegers.op_Plus",
"Prims.int",
"Pulse.Lib.BoundedIntegers.bounded_int_int"
] | [] | false | false | false | true | false | let add_nat_1 (x: nat) =
| x + 1 | false |
|
Pulse.Lib.BoundedIntegers.fst | Pulse.Lib.BoundedIntegers.bounded_unsigned_u32 | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bounded_unsigned_u32:bounded_unsigned FStar.UInt32.t | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bounded_unsigned_u32:bounded_unsigned FStar.UInt32.t | instance bounded_unsigned_u32 : bounded_unsigned FStar.UInt32.t = {
base = TC.solve;
max_bound = 0xfffffffful;
static_max_bound = true;
properties = ()
} | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.BoundedIntegers.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 1,
"end_line": 133,
"start_col": 0,
"start_line": 128
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.BoundedIntegers
module TC = FStar.Tactics.Typeclasses
let fits_t (fits:int -> prop) = x:int { fits x }
class bounded_int (t:eqtype) = {
fits: int -> prop;
v : t -> GTot int;
u : fits_t fits -> GTot t;
( + ) : (x:t -> y:t -> Pure t (requires fits (v x + v y)) (ensures fun z -> v z == v x + v y));
op_Subtraction : (x:t -> y:t -> Pure t (requires fits (v x - v y)) (ensures fun z -> v z == v x - v y));
( < ) : (x:t -> y:t -> b:bool { b = (v x < v y)});
( <= ) : (x:t -> y:t -> b:bool { b = (v x <= v y)});
( % ) : (x:t -> y:t -> Pure t (requires v y > 0 /\ fits (v x % v y)) (ensures fun z -> v z == v x % v y));
[@@@TC.no_method]
properties: squash (
(forall (x:t). {:pattern v x} fits (v x))
)
(* ...todo, add other ops **)
}
instance bounded_int_int : bounded_int int = {
fits = (fun _ -> True);
v = id;
u = id;
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y);
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
class bounded_unsigned (t:eqtype) = {
[@@@TC.no_method]
base:bounded_int t;
max_bound:t;
[@@@TC.no_method]
static_max_bound: bool;
[@@@TC.no_method]
properties: squash (
(forall (x:t). v x >= 0 /\ (static_max_bound ==> v x <= v max_bound)) /\
(forall (x:nat). x <= v max_bound ==> fits #t x)
)
}
instance bounded_from_bounded_unsigned (t:eqtype) (c:bounded_unsigned t) : bounded_int t = c.base
let safe_add (#t:eqtype) {| c: bounded_unsigned t |} (x y : t)
: o:option t { Some? o ==> v (Some?.v o) == v x + v y }
= if c.static_max_bound
then (
assert ( x <= max_bound);
if (y <= max_bound - x)
then Some (x + y)
else None
)
else (
if x <= max_bound
then (
assert (fits #t (v (max_bound #t) - v x));
if (y <= max_bound - x)
then Some (x + y)
else None
)
else None
)
let safe_mod (#t:eqtype) {| c: bounded_unsigned t |} (x : t) (y : t)
: Pure (option t)
(requires v y > 0)
(ensures fun o -> Some? o ==> v (Some?.v o) == v x % v y)
= if c.static_max_bound
then Some (x % y)
else (
if y <= max_bound
then (
assert (fits #t (v x % v y));
Some (x % y)
)
else None
)
let ok (#t:eqtype) {| c:bounded_int t |} (op: int -> int -> int) (x y:t) =
c.fits (op (v x) (v y))
let add (#t:eqtype) {| bounded_int t |} (x:t) (y:t { ok (+) x y }) = x + y
let add3 (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) z (x + y)}) = x + y + z
//Writing the signature of bounded_int.(+) using Pure
//allows this to work, since the type of (x+y) is not refined
let add3_alt (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) (x + y) z}) = x + y + z
instance bounded_int_u32 : bounded_int FStar.UInt32.t = {
fits = (fun x -> 0 <= x /\ x < 4294967296);
v = (fun x -> FStar.UInt32.v x);
u = FStar.UInt32.uint_to_t;
( + ) = (fun x y -> FStar.UInt32.add x y);
op_Subtraction = (fun x y -> FStar.UInt32.sub x y);
( < ) = FStar.UInt32.(fun x y -> x <^ y);
( <= ) = FStar.UInt32.(fun x y -> x <=^ y);
( % ) = FStar.UInt32.(fun x y -> x %^ y);
properties = ()
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Lib.BoundedIntegers.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": "TC"
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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 | Pulse.Lib.BoundedIntegers.bounded_unsigned FStar.UInt32.t | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.BoundedIntegers.Mkbounded_unsigned",
"FStar.UInt32.t",
"Pulse.Lib.BoundedIntegers.bounded_int_u32",
"Pulse.Lib.BoundedIntegers.bounded_int",
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let bounded_unsigned_u32:bounded_unsigned FStar.UInt32.t =
| { base = TC.solve; max_bound = 0xfffffffful; static_max_bound = true; properties = () } | false |
Vale.AES.GCM_s.fst | Vale.AES.GCM_s.gcm_decrypt_LE_reveal | val gcm_decrypt_LE_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.AES.GCM_s.gcm_decrypt_LE == Vale.AES.GCM_s.gcm_decrypt_LE_def) | let gcm_decrypt_LE_reveal = opaque_revealer (`%gcm_decrypt_LE) gcm_decrypt_LE gcm_decrypt_LE_def | {
"file_name": "vale/specs/crypto/Vale.AES.GCM_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 108,
"end_line": 96,
"start_col": 12,
"start_line": 96
} | module Vale.AES.GCM_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GHash_s
open FStar.Seq
open FStar.Mul
unfold type gcm_plain_LE = gctr_plain_LE
unfold type gcm_auth_LE = gctr_plain_LE
#reset-options "--z3rlimit 30"
type supported_iv_LE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 }
let compute_iv_BE_def (h_LE:quad32) (iv:supported_iv_LE) : quad32
=
if 8 * (length iv) = 96 then (
let iv_LE = le_bytes_to_quad32 (pad_to_128_bits iv) in
let iv_BE = reverse_bytes_quad32 iv_LE in
let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in
j0_BE
) else (
let padded_iv_quads = le_bytes_to_seq_quad32 (pad_to_128_bits iv) in
let length_BE = insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0 in
let length_LE = reverse_bytes_quad32 length_BE in
let hash_input_LE = append padded_iv_quads (create 1 length_LE) in
let hash_output_LE = ghash_LE h_LE hash_input_LE in
reverse_bytes_quad32 hash_output_LE
)
[@"opaque_to_smt"] let compute_iv_BE = opaque_make compute_iv_BE_def
irreducible let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def
// little-endian
let gcm_encrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (plain:seq nat8) (auth:seq nat8) :
Pure (seq nat8 & seq nat8)
(requires
is_aes_key alg key /\
length plain < pow2_32 /\
length auth < pow2_32
)
(ensures fun (c, t) -> True)
=
let key_LE = seq_nat8_to_seq_nat32_LE key in
let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_LE iv in
let c = gctr_encrypt_LE (inc32 j0_BE 1) plain alg key_LE in
// Sets the first 64-bit number to 8 * length plain, and the second to 8* length auth
let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0 in
let lengths_LE = reverse_bytes_quad32 lengths_BE in
let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits c) in
let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in
let s_LE = ghash_LE h_LE hash_input_LE in
let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in
(c, t)
[@"opaque_to_smt"] let gcm_encrypt_LE = opaque_make gcm_encrypt_LE_def
irreducible let gcm_encrypt_LE_reveal = opaque_revealer (`%gcm_encrypt_LE) gcm_encrypt_LE gcm_encrypt_LE_def
let gcm_decrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (cipher:seq nat8) (auth:seq nat8) (tag:seq nat8) :
Pure (seq nat8 & bool)
(requires
is_aes_key alg key /\
length cipher < pow2_32 /\
length auth < pow2_32
)
(ensures fun (p, t) -> True)
=
let key_LE = seq_nat8_to_seq_nat32_LE key in
let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_LE iv in
let p = gctr_encrypt_LE (inc32 j0_BE 1) cipher alg key_LE in // TODO: Rename gctr_encrypt_LE to gctr_LE
let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length cipher) 0 in
let lengths_LE = reverse_bytes_quad32 lengths_BE in
let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in
let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in
let s_LE = ghash_LE h_LE hash_input_LE in
let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in
(p, t = tag) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GCM_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.AES.GCM_s.gcm_decrypt_LE == Vale.AES.GCM_s.gcm_decrypt_LE_def) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Pervasives.Native.tuple2",
"Prims.bool",
"Prims.l_and",
"Vale.AES.AES_common_s.is_aes_key",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Vale.Def.Words_s.pow2_32",
"Prims.l_True",
"Vale.AES.GCM_s.gcm_decrypt_LE",
"Vale.AES.GCM_s.gcm_decrypt_LE_def"
] | [] | true | false | true | false | false | let gcm_decrypt_LE_reveal =
| opaque_revealer (`%gcm_decrypt_LE) gcm_decrypt_LE gcm_decrypt_LE_def | false |
|
Pulse.Lib.BoundedIntegers.fst | Pulse.Lib.BoundedIntegers.bounded_int_u32 | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bounded_int_u32:bounded_int FStar.UInt32.t | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bounded_int_u32:bounded_int FStar.UInt32.t | instance bounded_int_u32 : bounded_int FStar.UInt32.t = {
fits = (fun x -> 0 <= x /\ x < 4294967296);
v = (fun x -> FStar.UInt32.v x);
u = FStar.UInt32.uint_to_t;
( + ) = (fun x y -> FStar.UInt32.add x y);
op_Subtraction = (fun x y -> FStar.UInt32.sub x y);
( < ) = FStar.UInt32.(fun x y -> x <^ y);
( <= ) = FStar.UInt32.(fun x y -> x <=^ y);
( % ) = FStar.UInt32.(fun x y -> x %^ y);
properties = ()
} | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.BoundedIntegers.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 1,
"end_line": 126,
"start_col": 0,
"start_line": 116
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.BoundedIntegers
module TC = FStar.Tactics.Typeclasses
let fits_t (fits:int -> prop) = x:int { fits x }
class bounded_int (t:eqtype) = {
fits: int -> prop;
v : t -> GTot int;
u : fits_t fits -> GTot t;
( + ) : (x:t -> y:t -> Pure t (requires fits (v x + v y)) (ensures fun z -> v z == v x + v y));
op_Subtraction : (x:t -> y:t -> Pure t (requires fits (v x - v y)) (ensures fun z -> v z == v x - v y));
( < ) : (x:t -> y:t -> b:bool { b = (v x < v y)});
( <= ) : (x:t -> y:t -> b:bool { b = (v x <= v y)});
( % ) : (x:t -> y:t -> Pure t (requires v y > 0 /\ fits (v x % v y)) (ensures fun z -> v z == v x % v y));
[@@@TC.no_method]
properties: squash (
(forall (x:t). {:pattern v x} fits (v x))
)
(* ...todo, add other ops **)
}
instance bounded_int_int : bounded_int int = {
fits = (fun _ -> True);
v = id;
u = id;
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y);
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
class bounded_unsigned (t:eqtype) = {
[@@@TC.no_method]
base:bounded_int t;
max_bound:t;
[@@@TC.no_method]
static_max_bound: bool;
[@@@TC.no_method]
properties: squash (
(forall (x:t). v x >= 0 /\ (static_max_bound ==> v x <= v max_bound)) /\
(forall (x:nat). x <= v max_bound ==> fits #t x)
)
}
instance bounded_from_bounded_unsigned (t:eqtype) (c:bounded_unsigned t) : bounded_int t = c.base
let safe_add (#t:eqtype) {| c: bounded_unsigned t |} (x y : t)
: o:option t { Some? o ==> v (Some?.v o) == v x + v y }
= if c.static_max_bound
then (
assert ( x <= max_bound);
if (y <= max_bound - x)
then Some (x + y)
else None
)
else (
if x <= max_bound
then (
assert (fits #t (v (max_bound #t) - v x));
if (y <= max_bound - x)
then Some (x + y)
else None
)
else None
)
let safe_mod (#t:eqtype) {| c: bounded_unsigned t |} (x : t) (y : t)
: Pure (option t)
(requires v y > 0)
(ensures fun o -> Some? o ==> v (Some?.v o) == v x % v y)
= if c.static_max_bound
then Some (x % y)
else (
if y <= max_bound
then (
assert (fits #t (v x % v y));
Some (x % y)
)
else None
)
let ok (#t:eqtype) {| c:bounded_int t |} (op: int -> int -> int) (x y:t) =
c.fits (op (v x) (v y))
let add (#t:eqtype) {| bounded_int t |} (x:t) (y:t { ok (+) x y }) = x + y
let add3 (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) z (x + y)}) = x + y + z
//Writing the signature of bounded_int.(+) using Pure
//allows this to work, since the type of (x+y) is not refined
let add3_alt (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) (x + y) z}) = x + y + z | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Lib.BoundedIntegers.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": "TC"
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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 | Pulse.Lib.BoundedIntegers.bounded_int FStar.UInt32.t | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.BoundedIntegers.Mkbounded_int",
"FStar.UInt32.t",
"Prims.int",
"Prims.l_and",
"Prims.b2t",
"Pulse.Lib.BoundedIntegers.op_Less_Equals",
"Pulse.Lib.BoundedIntegers.bounded_int_int",
"Pulse.Lib.BoundedIntegers.op_Less",
"Prims.prop",
"FStar.UInt32.v",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.add",
"FStar.UInt32.sub",
"FStar.UInt32.op_Less_Hat",
"Prims.bool",
"Prims.op_Equality",
"Prims.op_LessThan",
"FStar.UInt32.op_Less_Equals_Hat",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.op_Percent_Hat"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let bounded_int_u32:bounded_int FStar.UInt32.t =
| {
fits = (fun x -> 0 <= x /\ x < 4294967296);
v = (fun x -> FStar.UInt32.v x);
u = FStar.UInt32.uint_to_t;
( + ) = (fun x y -> FStar.UInt32.add x y);
( - ) = (fun x y -> FStar.UInt32.sub x y);
( < ) = (let open FStar.UInt32 in fun x y -> x <^ y);
( <= ) = (let open FStar.UInt32 in fun x y -> x <=^ y);
( % ) = (let open FStar.UInt32 in fun x y -> x %^ y);
properties = ()
} | false |
Spec.Curve25519.fst | Spec.Curve25519.basepoint_lseq | val basepoint_lseq:Lib.Sequence.lseq byte_t 32 | val basepoint_lseq:Lib.Sequence.lseq byte_t 32 | let basepoint_lseq : Lib.Sequence.lseq byte_t 32 =
Lib.Sequence.of_list basepoint_list | {
"file_name": "specs/Spec.Curve25519.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 37,
"end_line": 137,
"start_col": 0,
"start_line": 136
} | module Spec.Curve25519
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Curve25519.Lemmas
#set-options "--z3rlimit 30 --ifuel 0 --fuel 0"
(* Field types and parameters *)
let prime : pos = pow2 255 - 19
type elem = x:nat{x < prime}
let zero : elem = 0
let one : elem = 1
let fadd (x:elem) (y:elem) : elem = (x + y) % prime
let fsub (x:elem) (y:elem) : elem = (x - y) % prime
let fmul (x:elem) (y:elem) : elem = (x * y) % prime
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b
let ( **% ) = fpow
let finv (x:elem) : elem = x **% (prime - 2)
let ( /% ) (x:elem) (y:elem) = x *% finv y
(* Type aliases *)
type scalar = lbytes 32
type serialized_point = lbytes 32
type proj_point = elem & elem
let ith_bit (k:scalar) (i:nat{i < 256}) : uint64 =
let q = i / 8 in let r = size (i % 8) in
to_u64 ((k.[q] >>. r) &. u8 1)
let decodeScalar (k:scalar) =
let k : scalar = k.[0] <- (k.[0] &. u8 248) in
let k : scalar = k.[31] <- (k.[31] &. u8 127) in
let k : scalar = k.[31] <- (k.[31] |. u8 64) in k
let decodePoint (u:serialized_point) =
(nat_from_bytes_le u % pow2 255) % prime
let encodePoint (p:proj_point) : Tot serialized_point =
let x, z = p in
let p = x /% z in
nat_to_bytes_le 32 p
let add_and_double q nq nqp1 =
let x_1, z_1 = q in
let x_2, z_2 = nq in
let x_3, z_3 = nqp1 in
let a = x_2 +% z_2 in
let b = x_2 -% z_2 in
let c = x_3 +% z_3 in
let d = x_3 -% z_3 in
let da = d *% a in
let cb = c *% b in
let x_3 = da +% cb in
let z_3 = da -% cb in
let aa = a *% a in
let bb = b *% b in
let x_3 = x_3 *% x_3 in
let z_3 = z_3 *% z_3 in
let e = aa -% bb in
let e121665 = e *% 121665 in
let aa_e121665 = e121665 +% aa in
let x_2 = aa *% bb in
let z_2 = e *% aa_e121665 in
let z_3 = z_3 *% x_1 in
(x_2, z_2), (x_3, z_3)
let double nq =
let x_2, z_2 = nq in
let a = x_2 +% z_2 in
let b = x_2 -% z_2 in
let aa = a *% a in
let bb = b *% b in
let e = aa -% bb in
let e121665 = e *% 121665 in
let aa_e121665 = e121665 +% aa in
let x_2 = aa *% bb in
let z_2 = e *% aa_e121665 in
x_2, z_2
let cswap2 (sw:uint64) (nq:proj_point) (nqp1:proj_point) =
let open Lib.RawIntTypes in
if uint_to_nat sw = 1 then (nqp1, nq) else (nq, nqp1)
let ladder_step (k:scalar) (q:proj_point) (i:nat{i < 251}) (nq, nqp1, swap) =
let bit = ith_bit k (253-i) in
let sw = swap ^. bit in
let nq, nqp1 = cswap2 sw nq nqp1 in
let nq, nqp1 = add_and_double q nq nqp1 in
(nq, nqp1, bit)
let montgomery_ladder (init:elem) (k:scalar) : Tot proj_point =
let q = (init, one) in
let nq = (one, zero) in
let nqp1 = (init, one) in
// bit 255 is 0 and bit 254 is 1
let nq,nqp1 = cswap2 (u64 1) nq nqp1 in
let nq,nqp1 = add_and_double q nq nqp1 in
let swap = u64 1 in
// bits 253-3 depend on scalar
let nq,nqp1,swap = Lib.LoopCombinators.repeati 251 (ladder_step k q) (nq, nqp1, swap) in
let nq,nqp1 = cswap2 swap nq nqp1 in
// bits 2-0 are 0
let nq = double nq in
let nq = double nq in
let nq = double nq in
nq
let scalarmult (k:scalar) (u:serialized_point) : Tot serialized_point =
let u = decodePoint u in
let res = montgomery_ladder u k in
encodePoint res
inline_for_extraction
let basepoint_list : x:list byte_t{List.Tot.length x == 32} =
[@inline_let]
let l =
[9uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy;
0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy;
0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy;
0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy] in
assert_norm (List.Tot.length l == 32);
l | {
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Curve25519.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Curve25519.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.PUB) 32 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.PUB",
"Spec.Curve25519.basepoint_list"
] | [] | false | false | false | false | false | let basepoint_lseq:Lib.Sequence.lseq byte_t 32 =
| Lib.Sequence.of_list basepoint_list | false |
Pulse.Lib.BoundedIntegers.fst | Pulse.Lib.BoundedIntegers.safe_add | val safe_add (#t: eqtype) {| c: bounded_unsigned t |} (x y: t)
: o: option t {Some? o ==> v (Some?.v o) == v x + v y} | val safe_add (#t: eqtype) {| c: bounded_unsigned t |} (x y: t)
: o: option t {Some? o ==> v (Some?.v o) == v x + v y} | let safe_add (#t:eqtype) {| c: bounded_unsigned t |} (x y : t)
: o:option t { Some? o ==> v (Some?.v o) == v x + v y }
= if c.static_max_bound
then (
assert ( x <= max_bound);
if (y <= max_bound - x)
then Some (x + y)
else None
)
else (
if x <= max_bound
then (
assert (fits #t (v (max_bound #t) - v x));
if (y <= max_bound - x)
then Some (x + y)
else None
)
else None
) | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.BoundedIntegers.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 5,
"end_line": 88,
"start_col": 0,
"start_line": 70
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.BoundedIntegers
module TC = FStar.Tactics.Typeclasses
let fits_t (fits:int -> prop) = x:int { fits x }
class bounded_int (t:eqtype) = {
fits: int -> prop;
v : t -> GTot int;
u : fits_t fits -> GTot t;
( + ) : (x:t -> y:t -> Pure t (requires fits (v x + v y)) (ensures fun z -> v z == v x + v y));
op_Subtraction : (x:t -> y:t -> Pure t (requires fits (v x - v y)) (ensures fun z -> v z == v x - v y));
( < ) : (x:t -> y:t -> b:bool { b = (v x < v y)});
( <= ) : (x:t -> y:t -> b:bool { b = (v x <= v y)});
( % ) : (x:t -> y:t -> Pure t (requires v y > 0 /\ fits (v x % v y)) (ensures fun z -> v z == v x % v y));
[@@@TC.no_method]
properties: squash (
(forall (x:t). {:pattern v x} fits (v x))
)
(* ...todo, add other ops **)
}
instance bounded_int_int : bounded_int int = {
fits = (fun _ -> True);
v = id;
u = id;
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y);
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
class bounded_unsigned (t:eqtype) = {
[@@@TC.no_method]
base:bounded_int t;
max_bound:t;
[@@@TC.no_method]
static_max_bound: bool;
[@@@TC.no_method]
properties: squash (
(forall (x:t). v x >= 0 /\ (static_max_bound ==> v x <= v max_bound)) /\
(forall (x:nat). x <= v max_bound ==> fits #t x)
)
}
instance bounded_from_bounded_unsigned (t:eqtype) (c:bounded_unsigned t) : bounded_int t = c.base | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Lib.BoundedIntegers.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": "TC"
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | {| c: Pulse.Lib.BoundedIntegers.bounded_unsigned t |} -> x: t -> y: t
-> o:
FStar.Pervasives.Native.option t
{ Some? o ==>
Pulse.Lib.BoundedIntegers.v (Some?.v o) ==
Pulse.Lib.BoundedIntegers.v x + Pulse.Lib.BoundedIntegers.v y } | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Pulse.Lib.BoundedIntegers.bounded_unsigned",
"Pulse.Lib.BoundedIntegers.__proj__Mkbounded_unsigned__item__static_max_bound",
"Pulse.Lib.BoundedIntegers.op_Less_Equals",
"Pulse.Lib.BoundedIntegers.bounded_from_bounded_unsigned",
"Pulse.Lib.BoundedIntegers.op_Subtraction",
"Pulse.Lib.BoundedIntegers.max_bound",
"FStar.Pervasives.Native.Some",
"Pulse.Lib.BoundedIntegers.op_Plus",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"Prims.l_imp",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"Prims.eq2",
"Prims.int",
"Pulse.Lib.BoundedIntegers.v",
"FStar.Pervasives.Native.__proj__Some__item__v",
"Pulse.Lib.BoundedIntegers.bounded_int_int",
"Prims.unit",
"Prims._assert",
"Pulse.Lib.BoundedIntegers.fits"
] | [] | false | false | false | false | false | let safe_add (#t: eqtype) {| c: bounded_unsigned t |} (x y: t)
: o: option t {Some? o ==> v (Some?.v o) == v x + v y} =
| if c.static_max_bound
then
(assert (x <= max_bound);
if (y <= max_bound - x) then Some (x + y) else None)
else
(if x <= max_bound
then
(assert (fits #t (v (max_bound #t) - v x));
if (y <= max_bound - x) then Some (x + y) else None)
else None) | false |
Spec.Curve25519.fst | Spec.Curve25519.scalarmult | val scalarmult (k: scalar) (u: serialized_point) : Tot serialized_point | val scalarmult (k: scalar) (u: serialized_point) : Tot serialized_point | let scalarmult (k:scalar) (u:serialized_point) : Tot serialized_point =
let u = decodePoint u in
let res = montgomery_ladder u k in
encodePoint res | {
"file_name": "specs/Spec.Curve25519.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 123,
"start_col": 0,
"start_line": 120
} | module Spec.Curve25519
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Curve25519.Lemmas
#set-options "--z3rlimit 30 --ifuel 0 --fuel 0"
(* Field types and parameters *)
let prime : pos = pow2 255 - 19
type elem = x:nat{x < prime}
let zero : elem = 0
let one : elem = 1
let fadd (x:elem) (y:elem) : elem = (x + y) % prime
let fsub (x:elem) (y:elem) : elem = (x - y) % prime
let fmul (x:elem) (y:elem) : elem = (x * y) % prime
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b
let ( **% ) = fpow
let finv (x:elem) : elem = x **% (prime - 2)
let ( /% ) (x:elem) (y:elem) = x *% finv y
(* Type aliases *)
type scalar = lbytes 32
type serialized_point = lbytes 32
type proj_point = elem & elem
let ith_bit (k:scalar) (i:nat{i < 256}) : uint64 =
let q = i / 8 in let r = size (i % 8) in
to_u64 ((k.[q] >>. r) &. u8 1)
let decodeScalar (k:scalar) =
let k : scalar = k.[0] <- (k.[0] &. u8 248) in
let k : scalar = k.[31] <- (k.[31] &. u8 127) in
let k : scalar = k.[31] <- (k.[31] |. u8 64) in k
let decodePoint (u:serialized_point) =
(nat_from_bytes_le u % pow2 255) % prime
let encodePoint (p:proj_point) : Tot serialized_point =
let x, z = p in
let p = x /% z in
nat_to_bytes_le 32 p
let add_and_double q nq nqp1 =
let x_1, z_1 = q in
let x_2, z_2 = nq in
let x_3, z_3 = nqp1 in
let a = x_2 +% z_2 in
let b = x_2 -% z_2 in
let c = x_3 +% z_3 in
let d = x_3 -% z_3 in
let da = d *% a in
let cb = c *% b in
let x_3 = da +% cb in
let z_3 = da -% cb in
let aa = a *% a in
let bb = b *% b in
let x_3 = x_3 *% x_3 in
let z_3 = z_3 *% z_3 in
let e = aa -% bb in
let e121665 = e *% 121665 in
let aa_e121665 = e121665 +% aa in
let x_2 = aa *% bb in
let z_2 = e *% aa_e121665 in
let z_3 = z_3 *% x_1 in
(x_2, z_2), (x_3, z_3)
let double nq =
let x_2, z_2 = nq in
let a = x_2 +% z_2 in
let b = x_2 -% z_2 in
let aa = a *% a in
let bb = b *% b in
let e = aa -% bb in
let e121665 = e *% 121665 in
let aa_e121665 = e121665 +% aa in
let x_2 = aa *% bb in
let z_2 = e *% aa_e121665 in
x_2, z_2
let cswap2 (sw:uint64) (nq:proj_point) (nqp1:proj_point) =
let open Lib.RawIntTypes in
if uint_to_nat sw = 1 then (nqp1, nq) else (nq, nqp1)
let ladder_step (k:scalar) (q:proj_point) (i:nat{i < 251}) (nq, nqp1, swap) =
let bit = ith_bit k (253-i) in
let sw = swap ^. bit in
let nq, nqp1 = cswap2 sw nq nqp1 in
let nq, nqp1 = add_and_double q nq nqp1 in
(nq, nqp1, bit)
let montgomery_ladder (init:elem) (k:scalar) : Tot proj_point =
let q = (init, one) in
let nq = (one, zero) in
let nqp1 = (init, one) in
// bit 255 is 0 and bit 254 is 1
let nq,nqp1 = cswap2 (u64 1) nq nqp1 in
let nq,nqp1 = add_and_double q nq nqp1 in
let swap = u64 1 in
// bits 253-3 depend on scalar
let nq,nqp1,swap = Lib.LoopCombinators.repeati 251 (ladder_step k q) (nq, nqp1, swap) in
let nq,nqp1 = cswap2 swap nq nqp1 in
// bits 2-0 are 0
let nq = double nq in
let nq = double nq in
let nq = double nq in
nq | {
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Curve25519.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Curve25519.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Spec.Curve25519.scalar -> u81: Spec.Curve25519.serialized_point
-> Spec.Curve25519.serialized_point | Prims.Tot | [
"total"
] | [] | [
"Spec.Curve25519.scalar",
"Spec.Curve25519.serialized_point",
"Spec.Curve25519.encodePoint",
"Spec.Curve25519.proj_point",
"Spec.Curve25519.montgomery_ladder",
"Prims.int",
"Spec.Curve25519.decodePoint"
] | [] | false | false | false | true | false | let scalarmult (k: scalar) (u: serialized_point) : Tot serialized_point =
| let u = decodePoint u in
let res = montgomery_ladder u k in
encodePoint res | false |
Pulse.Lib.BoundedIntegers.fst | Pulse.Lib.BoundedIntegers.bounded_unsigned_u64 | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bounded_unsigned_u64:bounded_unsigned FStar.UInt64.t | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bounded_unsigned_u64:bounded_unsigned FStar.UInt64.t | instance bounded_unsigned_u64 : bounded_unsigned FStar.UInt64.t = {
base = TC.solve;
max_bound = 0xffffffffffffffffuL;
static_max_bound = true;
properties = ()
} | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.BoundedIntegers.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 1,
"end_line": 152,
"start_col": 0,
"start_line": 147
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.BoundedIntegers
module TC = FStar.Tactics.Typeclasses
let fits_t (fits:int -> prop) = x:int { fits x }
class bounded_int (t:eqtype) = {
fits: int -> prop;
v : t -> GTot int;
u : fits_t fits -> GTot t;
( + ) : (x:t -> y:t -> Pure t (requires fits (v x + v y)) (ensures fun z -> v z == v x + v y));
op_Subtraction : (x:t -> y:t -> Pure t (requires fits (v x - v y)) (ensures fun z -> v z == v x - v y));
( < ) : (x:t -> y:t -> b:bool { b = (v x < v y)});
( <= ) : (x:t -> y:t -> b:bool { b = (v x <= v y)});
( % ) : (x:t -> y:t -> Pure t (requires v y > 0 /\ fits (v x % v y)) (ensures fun z -> v z == v x % v y));
[@@@TC.no_method]
properties: squash (
(forall (x:t). {:pattern v x} fits (v x))
)
(* ...todo, add other ops **)
}
instance bounded_int_int : bounded_int int = {
fits = (fun _ -> True);
v = id;
u = id;
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y);
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
class bounded_unsigned (t:eqtype) = {
[@@@TC.no_method]
base:bounded_int t;
max_bound:t;
[@@@TC.no_method]
static_max_bound: bool;
[@@@TC.no_method]
properties: squash (
(forall (x:t). v x >= 0 /\ (static_max_bound ==> v x <= v max_bound)) /\
(forall (x:nat). x <= v max_bound ==> fits #t x)
)
}
instance bounded_from_bounded_unsigned (t:eqtype) (c:bounded_unsigned t) : bounded_int t = c.base
let safe_add (#t:eqtype) {| c: bounded_unsigned t |} (x y : t)
: o:option t { Some? o ==> v (Some?.v o) == v x + v y }
= if c.static_max_bound
then (
assert ( x <= max_bound);
if (y <= max_bound - x)
then Some (x + y)
else None
)
else (
if x <= max_bound
then (
assert (fits #t (v (max_bound #t) - v x));
if (y <= max_bound - x)
then Some (x + y)
else None
)
else None
)
let safe_mod (#t:eqtype) {| c: bounded_unsigned t |} (x : t) (y : t)
: Pure (option t)
(requires v y > 0)
(ensures fun o -> Some? o ==> v (Some?.v o) == v x % v y)
= if c.static_max_bound
then Some (x % y)
else (
if y <= max_bound
then (
assert (fits #t (v x % v y));
Some (x % y)
)
else None
)
let ok (#t:eqtype) {| c:bounded_int t |} (op: int -> int -> int) (x y:t) =
c.fits (op (v x) (v y))
let add (#t:eqtype) {| bounded_int t |} (x:t) (y:t { ok (+) x y }) = x + y
let add3 (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) z (x + y)}) = x + y + z
//Writing the signature of bounded_int.(+) using Pure
//allows this to work, since the type of (x+y) is not refined
let add3_alt (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) (x + y) z}) = x + y + z
instance bounded_int_u32 : bounded_int FStar.UInt32.t = {
fits = (fun x -> 0 <= x /\ x < 4294967296);
v = (fun x -> FStar.UInt32.v x);
u = FStar.UInt32.uint_to_t;
( + ) = (fun x y -> FStar.UInt32.add x y);
op_Subtraction = (fun x y -> FStar.UInt32.sub x y);
( < ) = FStar.UInt32.(fun x y -> x <^ y);
( <= ) = FStar.UInt32.(fun x y -> x <=^ y);
( % ) = FStar.UInt32.(fun x y -> x %^ y);
properties = ()
}
instance bounded_unsigned_u32 : bounded_unsigned FStar.UInt32.t = {
base = TC.solve;
max_bound = 0xfffffffful;
static_max_bound = true;
properties = ()
}
instance bounded_int_u64 : bounded_int FStar.UInt64.t = {
fits = (fun x -> 0 <= x /\ x <= 0xffffffffffffffff);
v = (fun x -> FStar.UInt64.v x);
u = FStar.UInt64.uint_to_t;
( + ) = (fun x y -> FStar.UInt64.add x y);
op_Subtraction = (fun x y -> FStar.UInt64.sub x y);
( < ) = FStar.UInt64.(fun x y -> x <^ y);
( <= ) = FStar.UInt64.(fun x y -> x <=^ y);
( % ) = FStar.UInt64.(fun x y -> x %^ y);
properties = ()
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Lib.BoundedIntegers.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": "TC"
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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 | Pulse.Lib.BoundedIntegers.bounded_unsigned FStar.UInt64.t | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.BoundedIntegers.Mkbounded_unsigned",
"FStar.UInt64.t",
"Pulse.Lib.BoundedIntegers.bounded_int_u64",
"Pulse.Lib.BoundedIntegers.bounded_int",
"FStar.UInt64.__uint_to_t"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let bounded_unsigned_u64:bounded_unsigned FStar.UInt64.t =
| { base = TC.solve; max_bound = 0xffffffffffffffffuL; static_max_bound = true; properties = () } | false |
Pulse.Lib.BoundedIntegers.fst | Pulse.Lib.BoundedIntegers.bounded_int_pos | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bounded_int_pos:bounded_int pos | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bounded_int_pos:bounded_int pos | instance bounded_int_pos : bounded_int pos = {
fits = (fun x -> x > 0);
v = pos_as_int;
u = (fun x -> x);
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y); //can't write ( - ), it doesn't parse
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
} | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.BoundedIntegers.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 1,
"end_line": 197,
"start_col": 0,
"start_line": 187
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.BoundedIntegers
module TC = FStar.Tactics.Typeclasses
let fits_t (fits:int -> prop) = x:int { fits x }
class bounded_int (t:eqtype) = {
fits: int -> prop;
v : t -> GTot int;
u : fits_t fits -> GTot t;
( + ) : (x:t -> y:t -> Pure t (requires fits (v x + v y)) (ensures fun z -> v z == v x + v y));
op_Subtraction : (x:t -> y:t -> Pure t (requires fits (v x - v y)) (ensures fun z -> v z == v x - v y));
( < ) : (x:t -> y:t -> b:bool { b = (v x < v y)});
( <= ) : (x:t -> y:t -> b:bool { b = (v x <= v y)});
( % ) : (x:t -> y:t -> Pure t (requires v y > 0 /\ fits (v x % v y)) (ensures fun z -> v z == v x % v y));
[@@@TC.no_method]
properties: squash (
(forall (x:t). {:pattern v x} fits (v x))
)
(* ...todo, add other ops **)
}
instance bounded_int_int : bounded_int int = {
fits = (fun _ -> True);
v = id;
u = id;
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y);
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
class bounded_unsigned (t:eqtype) = {
[@@@TC.no_method]
base:bounded_int t;
max_bound:t;
[@@@TC.no_method]
static_max_bound: bool;
[@@@TC.no_method]
properties: squash (
(forall (x:t). v x >= 0 /\ (static_max_bound ==> v x <= v max_bound)) /\
(forall (x:nat). x <= v max_bound ==> fits #t x)
)
}
instance bounded_from_bounded_unsigned (t:eqtype) (c:bounded_unsigned t) : bounded_int t = c.base
let safe_add (#t:eqtype) {| c: bounded_unsigned t |} (x y : t)
: o:option t { Some? o ==> v (Some?.v o) == v x + v y }
= if c.static_max_bound
then (
assert ( x <= max_bound);
if (y <= max_bound - x)
then Some (x + y)
else None
)
else (
if x <= max_bound
then (
assert (fits #t (v (max_bound #t) - v x));
if (y <= max_bound - x)
then Some (x + y)
else None
)
else None
)
let safe_mod (#t:eqtype) {| c: bounded_unsigned t |} (x : t) (y : t)
: Pure (option t)
(requires v y > 0)
(ensures fun o -> Some? o ==> v (Some?.v o) == v x % v y)
= if c.static_max_bound
then Some (x % y)
else (
if y <= max_bound
then (
assert (fits #t (v x % v y));
Some (x % y)
)
else None
)
let ok (#t:eqtype) {| c:bounded_int t |} (op: int -> int -> int) (x y:t) =
c.fits (op (v x) (v y))
let add (#t:eqtype) {| bounded_int t |} (x:t) (y:t { ok (+) x y }) = x + y
let add3 (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) z (x + y)}) = x + y + z
//Writing the signature of bounded_int.(+) using Pure
//allows this to work, since the type of (x+y) is not refined
let add3_alt (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) (x + y) z}) = x + y + z
instance bounded_int_u32 : bounded_int FStar.UInt32.t = {
fits = (fun x -> 0 <= x /\ x < 4294967296);
v = (fun x -> FStar.UInt32.v x);
u = FStar.UInt32.uint_to_t;
( + ) = (fun x y -> FStar.UInt32.add x y);
op_Subtraction = (fun x y -> FStar.UInt32.sub x y);
( < ) = FStar.UInt32.(fun x y -> x <^ y);
( <= ) = FStar.UInt32.(fun x y -> x <=^ y);
( % ) = FStar.UInt32.(fun x y -> x %^ y);
properties = ()
}
instance bounded_unsigned_u32 : bounded_unsigned FStar.UInt32.t = {
base = TC.solve;
max_bound = 0xfffffffful;
static_max_bound = true;
properties = ()
}
instance bounded_int_u64 : bounded_int FStar.UInt64.t = {
fits = (fun x -> 0 <= x /\ x <= 0xffffffffffffffff);
v = (fun x -> FStar.UInt64.v x);
u = FStar.UInt64.uint_to_t;
( + ) = (fun x y -> FStar.UInt64.add x y);
op_Subtraction = (fun x y -> FStar.UInt64.sub x y);
( < ) = FStar.UInt64.(fun x y -> x <^ y);
( <= ) = FStar.UInt64.(fun x y -> x <=^ y);
( % ) = FStar.UInt64.(fun x y -> x %^ y);
properties = ()
}
instance bounded_unsigned_u64 : bounded_unsigned FStar.UInt64.t = {
base = TC.solve;
max_bound = 0xffffffffffffffffuL;
static_max_bound = true;
properties = ()
}
let test (t:eqtype) {| _ : bounded_unsigned t |} (x:t) = v x
let add_u32 (x:FStar.UInt32.t) (y:FStar.UInt32.t { ok (+) x y }) = x + y
//Again, parser doesn't allow using (-)
let sub_u32 (x:FStar.UInt32.t) (y:FStar.UInt32.t { ok op_Subtraction x y}) = x - y
//this work and resolved to int, because of the 1
let add_nat_1 (x:nat) = x + 1
//But, to add two nats, this fails, since typeclass resolution doesn't consider subtyping
[@@expect_failure]
let add_nat (x y:nat) = x + y
let nat_as_int (x:nat) : int = x
instance bounded_int_nat : bounded_int nat = {
fits = (fun x -> x >= 0);
v = nat_as_int;
u = (fun x -> x);
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y); //can't write ( - ), it doesn't parse
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
//with an instance for nat this works
let add_nat (x y:nat) = x + y
//but we should find a way to make it work with refinement, otherwise we'll need instances for pos etc. too
let pos_as_int (x:pos) : int = x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Lib.BoundedIntegers.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": "TC"
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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 | Pulse.Lib.BoundedIntegers.bounded_int Prims.pos | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.BoundedIntegers.Mkbounded_int",
"Pulse.Lib.BoundedIntegers.fits_t",
"Prims.int",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.prop",
"Pulse.Lib.BoundedIntegers.pos_as_int",
"Prims.op_Addition",
"Prims.op_Subtraction",
"Prims.op_LessThan",
"Prims.bool",
"Prims.op_Equality",
"Prims.op_LessThanOrEqual",
"Prims.op_Modulus"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let bounded_int_pos:bounded_int pos =
| {
fits = (fun x -> x > 0);
v = pos_as_int;
u = (fun x -> x);
( + ) = (fun x y -> Prims.op_Addition x y);
( - ) = (fun x y -> Prims.op_Subtraction x y);
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
} | false |
Pulse.Lib.BoundedIntegers.fst | Pulse.Lib.BoundedIntegers.bounded_int_u64 | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bounded_int_u64:bounded_int FStar.UInt64.t | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bounded_int_u64:bounded_int FStar.UInt64.t | instance bounded_int_u64 : bounded_int FStar.UInt64.t = {
fits = (fun x -> 0 <= x /\ x <= 0xffffffffffffffff);
v = (fun x -> FStar.UInt64.v x);
u = FStar.UInt64.uint_to_t;
( + ) = (fun x y -> FStar.UInt64.add x y);
op_Subtraction = (fun x y -> FStar.UInt64.sub x y);
( < ) = FStar.UInt64.(fun x y -> x <^ y);
( <= ) = FStar.UInt64.(fun x y -> x <=^ y);
( % ) = FStar.UInt64.(fun x y -> x %^ y);
properties = ()
} | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.BoundedIntegers.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 1,
"end_line": 145,
"start_col": 0,
"start_line": 135
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.BoundedIntegers
module TC = FStar.Tactics.Typeclasses
let fits_t (fits:int -> prop) = x:int { fits x }
class bounded_int (t:eqtype) = {
fits: int -> prop;
v : t -> GTot int;
u : fits_t fits -> GTot t;
( + ) : (x:t -> y:t -> Pure t (requires fits (v x + v y)) (ensures fun z -> v z == v x + v y));
op_Subtraction : (x:t -> y:t -> Pure t (requires fits (v x - v y)) (ensures fun z -> v z == v x - v y));
( < ) : (x:t -> y:t -> b:bool { b = (v x < v y)});
( <= ) : (x:t -> y:t -> b:bool { b = (v x <= v y)});
( % ) : (x:t -> y:t -> Pure t (requires v y > 0 /\ fits (v x % v y)) (ensures fun z -> v z == v x % v y));
[@@@TC.no_method]
properties: squash (
(forall (x:t). {:pattern v x} fits (v x))
)
(* ...todo, add other ops **)
}
instance bounded_int_int : bounded_int int = {
fits = (fun _ -> True);
v = id;
u = id;
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y);
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
class bounded_unsigned (t:eqtype) = {
[@@@TC.no_method]
base:bounded_int t;
max_bound:t;
[@@@TC.no_method]
static_max_bound: bool;
[@@@TC.no_method]
properties: squash (
(forall (x:t). v x >= 0 /\ (static_max_bound ==> v x <= v max_bound)) /\
(forall (x:nat). x <= v max_bound ==> fits #t x)
)
}
instance bounded_from_bounded_unsigned (t:eqtype) (c:bounded_unsigned t) : bounded_int t = c.base
let safe_add (#t:eqtype) {| c: bounded_unsigned t |} (x y : t)
: o:option t { Some? o ==> v (Some?.v o) == v x + v y }
= if c.static_max_bound
then (
assert ( x <= max_bound);
if (y <= max_bound - x)
then Some (x + y)
else None
)
else (
if x <= max_bound
then (
assert (fits #t (v (max_bound #t) - v x));
if (y <= max_bound - x)
then Some (x + y)
else None
)
else None
)
let safe_mod (#t:eqtype) {| c: bounded_unsigned t |} (x : t) (y : t)
: Pure (option t)
(requires v y > 0)
(ensures fun o -> Some? o ==> v (Some?.v o) == v x % v y)
= if c.static_max_bound
then Some (x % y)
else (
if y <= max_bound
then (
assert (fits #t (v x % v y));
Some (x % y)
)
else None
)
let ok (#t:eqtype) {| c:bounded_int t |} (op: int -> int -> int) (x y:t) =
c.fits (op (v x) (v y))
let add (#t:eqtype) {| bounded_int t |} (x:t) (y:t { ok (+) x y }) = x + y
let add3 (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) z (x + y)}) = x + y + z
//Writing the signature of bounded_int.(+) using Pure
//allows this to work, since the type of (x+y) is not refined
let add3_alt (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) (x + y) z}) = x + y + z
instance bounded_int_u32 : bounded_int FStar.UInt32.t = {
fits = (fun x -> 0 <= x /\ x < 4294967296);
v = (fun x -> FStar.UInt32.v x);
u = FStar.UInt32.uint_to_t;
( + ) = (fun x y -> FStar.UInt32.add x y);
op_Subtraction = (fun x y -> FStar.UInt32.sub x y);
( < ) = FStar.UInt32.(fun x y -> x <^ y);
( <= ) = FStar.UInt32.(fun x y -> x <=^ y);
( % ) = FStar.UInt32.(fun x y -> x %^ y);
properties = ()
}
instance bounded_unsigned_u32 : bounded_unsigned FStar.UInt32.t = {
base = TC.solve;
max_bound = 0xfffffffful;
static_max_bound = true;
properties = ()
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Lib.BoundedIntegers.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": "TC"
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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 | Pulse.Lib.BoundedIntegers.bounded_int FStar.UInt64.t | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.BoundedIntegers.Mkbounded_int",
"FStar.UInt64.t",
"Prims.int",
"Prims.l_and",
"Prims.b2t",
"Pulse.Lib.BoundedIntegers.op_Less_Equals",
"Pulse.Lib.BoundedIntegers.bounded_int_int",
"Prims.prop",
"FStar.UInt64.v",
"FStar.UInt64.uint_to_t",
"FStar.UInt64.add",
"FStar.UInt64.sub",
"FStar.UInt64.op_Less_Hat",
"Prims.bool",
"Prims.op_Equality",
"Prims.op_LessThan",
"FStar.UInt64.op_Less_Equals_Hat",
"Prims.op_LessThanOrEqual",
"FStar.UInt64.op_Percent_Hat"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let bounded_int_u64:bounded_int FStar.UInt64.t =
| {
fits = (fun x -> 0 <= x /\ x <= 0xffffffffffffffff);
v = (fun x -> FStar.UInt64.v x);
u = FStar.UInt64.uint_to_t;
( + ) = (fun x y -> FStar.UInt64.add x y);
( - ) = (fun x y -> FStar.UInt64.sub x y);
( < ) = (let open FStar.UInt64 in fun x y -> x <^ y);
( <= ) = (let open FStar.UInt64 in fun x y -> x <=^ y);
( % ) = (let open FStar.UInt64 in fun x y -> x %^ y);
properties = ()
} | false |
Pulse.Lib.BoundedIntegers.fst | Pulse.Lib.BoundedIntegers.sub_u32 | val sub_u32 : x: FStar.UInt32.t ->
y: FStar.UInt32.t{Pulse.Lib.BoundedIntegers.ok Pulse.Lib.BoundedIntegers.op_Subtraction x y}
-> FStar.UInt32.t | let sub_u32 (x:FStar.UInt32.t) (y:FStar.UInt32.t { ok op_Subtraction x y}) = x - y | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.BoundedIntegers.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 82,
"end_line": 159,
"start_col": 0,
"start_line": 159
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.BoundedIntegers
module TC = FStar.Tactics.Typeclasses
let fits_t (fits:int -> prop) = x:int { fits x }
class bounded_int (t:eqtype) = {
fits: int -> prop;
v : t -> GTot int;
u : fits_t fits -> GTot t;
( + ) : (x:t -> y:t -> Pure t (requires fits (v x + v y)) (ensures fun z -> v z == v x + v y));
op_Subtraction : (x:t -> y:t -> Pure t (requires fits (v x - v y)) (ensures fun z -> v z == v x - v y));
( < ) : (x:t -> y:t -> b:bool { b = (v x < v y)});
( <= ) : (x:t -> y:t -> b:bool { b = (v x <= v y)});
( % ) : (x:t -> y:t -> Pure t (requires v y > 0 /\ fits (v x % v y)) (ensures fun z -> v z == v x % v y));
[@@@TC.no_method]
properties: squash (
(forall (x:t). {:pattern v x} fits (v x))
)
(* ...todo, add other ops **)
}
instance bounded_int_int : bounded_int int = {
fits = (fun _ -> True);
v = id;
u = id;
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y);
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
class bounded_unsigned (t:eqtype) = {
[@@@TC.no_method]
base:bounded_int t;
max_bound:t;
[@@@TC.no_method]
static_max_bound: bool;
[@@@TC.no_method]
properties: squash (
(forall (x:t). v x >= 0 /\ (static_max_bound ==> v x <= v max_bound)) /\
(forall (x:nat). x <= v max_bound ==> fits #t x)
)
}
instance bounded_from_bounded_unsigned (t:eqtype) (c:bounded_unsigned t) : bounded_int t = c.base
let safe_add (#t:eqtype) {| c: bounded_unsigned t |} (x y : t)
: o:option t { Some? o ==> v (Some?.v o) == v x + v y }
= if c.static_max_bound
then (
assert ( x <= max_bound);
if (y <= max_bound - x)
then Some (x + y)
else None
)
else (
if x <= max_bound
then (
assert (fits #t (v (max_bound #t) - v x));
if (y <= max_bound - x)
then Some (x + y)
else None
)
else None
)
let safe_mod (#t:eqtype) {| c: bounded_unsigned t |} (x : t) (y : t)
: Pure (option t)
(requires v y > 0)
(ensures fun o -> Some? o ==> v (Some?.v o) == v x % v y)
= if c.static_max_bound
then Some (x % y)
else (
if y <= max_bound
then (
assert (fits #t (v x % v y));
Some (x % y)
)
else None
)
let ok (#t:eqtype) {| c:bounded_int t |} (op: int -> int -> int) (x y:t) =
c.fits (op (v x) (v y))
let add (#t:eqtype) {| bounded_int t |} (x:t) (y:t { ok (+) x y }) = x + y
let add3 (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) z (x + y)}) = x + y + z
//Writing the signature of bounded_int.(+) using Pure
//allows this to work, since the type of (x+y) is not refined
let add3_alt (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) (x + y) z}) = x + y + z
instance bounded_int_u32 : bounded_int FStar.UInt32.t = {
fits = (fun x -> 0 <= x /\ x < 4294967296);
v = (fun x -> FStar.UInt32.v x);
u = FStar.UInt32.uint_to_t;
( + ) = (fun x y -> FStar.UInt32.add x y);
op_Subtraction = (fun x y -> FStar.UInt32.sub x y);
( < ) = FStar.UInt32.(fun x y -> x <^ y);
( <= ) = FStar.UInt32.(fun x y -> x <=^ y);
( % ) = FStar.UInt32.(fun x y -> x %^ y);
properties = ()
}
instance bounded_unsigned_u32 : bounded_unsigned FStar.UInt32.t = {
base = TC.solve;
max_bound = 0xfffffffful;
static_max_bound = true;
properties = ()
}
instance bounded_int_u64 : bounded_int FStar.UInt64.t = {
fits = (fun x -> 0 <= x /\ x <= 0xffffffffffffffff);
v = (fun x -> FStar.UInt64.v x);
u = FStar.UInt64.uint_to_t;
( + ) = (fun x y -> FStar.UInt64.add x y);
op_Subtraction = (fun x y -> FStar.UInt64.sub x y);
( < ) = FStar.UInt64.(fun x y -> x <^ y);
( <= ) = FStar.UInt64.(fun x y -> x <=^ y);
( % ) = FStar.UInt64.(fun x y -> x %^ y);
properties = ()
}
instance bounded_unsigned_u64 : bounded_unsigned FStar.UInt64.t = {
base = TC.solve;
max_bound = 0xffffffffffffffffuL;
static_max_bound = true;
properties = ()
}
let test (t:eqtype) {| _ : bounded_unsigned t |} (x:t) = v x
let add_u32 (x:FStar.UInt32.t) (y:FStar.UInt32.t { ok (+) x y }) = x + y | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Lib.BoundedIntegers.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": "TC"
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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: FStar.UInt32.t ->
y: FStar.UInt32.t{Pulse.Lib.BoundedIntegers.ok Pulse.Lib.BoundedIntegers.op_Subtraction x y}
-> FStar.UInt32.t | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"Pulse.Lib.BoundedIntegers.ok",
"Pulse.Lib.BoundedIntegers.bounded_int_u32",
"Pulse.Lib.BoundedIntegers.op_Subtraction",
"Prims.int",
"Pulse.Lib.BoundedIntegers.bounded_int_int"
] | [] | false | false | false | false | false | let sub_u32 (x: FStar.UInt32.t) (y: FStar.UInt32.t{ok op_Subtraction x y}) =
| x - y | false |
|
Pulse.Lib.BoundedIntegers.fst | Pulse.Lib.BoundedIntegers.bounded_unsigned_size_t | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bounded_unsigned_size_t:bounded_unsigned FStar.SizeT.t | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bounded_unsigned_size_t:bounded_unsigned FStar.SizeT.t | instance bounded_unsigned_size_t : bounded_unsigned FStar.SizeT.t = {
base = TC.solve;
max_bound = 0xffffsz;
static_max_bound = false;
properties = ()
} | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.BoundedIntegers.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 1,
"end_line": 219,
"start_col": 0,
"start_line": 214
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.BoundedIntegers
module TC = FStar.Tactics.Typeclasses
let fits_t (fits:int -> prop) = x:int { fits x }
class bounded_int (t:eqtype) = {
fits: int -> prop;
v : t -> GTot int;
u : fits_t fits -> GTot t;
( + ) : (x:t -> y:t -> Pure t (requires fits (v x + v y)) (ensures fun z -> v z == v x + v y));
op_Subtraction : (x:t -> y:t -> Pure t (requires fits (v x - v y)) (ensures fun z -> v z == v x - v y));
( < ) : (x:t -> y:t -> b:bool { b = (v x < v y)});
( <= ) : (x:t -> y:t -> b:bool { b = (v x <= v y)});
( % ) : (x:t -> y:t -> Pure t (requires v y > 0 /\ fits (v x % v y)) (ensures fun z -> v z == v x % v y));
[@@@TC.no_method]
properties: squash (
(forall (x:t). {:pattern v x} fits (v x))
)
(* ...todo, add other ops **)
}
instance bounded_int_int : bounded_int int = {
fits = (fun _ -> True);
v = id;
u = id;
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y);
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
class bounded_unsigned (t:eqtype) = {
[@@@TC.no_method]
base:bounded_int t;
max_bound:t;
[@@@TC.no_method]
static_max_bound: bool;
[@@@TC.no_method]
properties: squash (
(forall (x:t). v x >= 0 /\ (static_max_bound ==> v x <= v max_bound)) /\
(forall (x:nat). x <= v max_bound ==> fits #t x)
)
}
instance bounded_from_bounded_unsigned (t:eqtype) (c:bounded_unsigned t) : bounded_int t = c.base
let safe_add (#t:eqtype) {| c: bounded_unsigned t |} (x y : t)
: o:option t { Some? o ==> v (Some?.v o) == v x + v y }
= if c.static_max_bound
then (
assert ( x <= max_bound);
if (y <= max_bound - x)
then Some (x + y)
else None
)
else (
if x <= max_bound
then (
assert (fits #t (v (max_bound #t) - v x));
if (y <= max_bound - x)
then Some (x + y)
else None
)
else None
)
let safe_mod (#t:eqtype) {| c: bounded_unsigned t |} (x : t) (y : t)
: Pure (option t)
(requires v y > 0)
(ensures fun o -> Some? o ==> v (Some?.v o) == v x % v y)
= if c.static_max_bound
then Some (x % y)
else (
if y <= max_bound
then (
assert (fits #t (v x % v y));
Some (x % y)
)
else None
)
let ok (#t:eqtype) {| c:bounded_int t |} (op: int -> int -> int) (x y:t) =
c.fits (op (v x) (v y))
let add (#t:eqtype) {| bounded_int t |} (x:t) (y:t { ok (+) x y }) = x + y
let add3 (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) z (x + y)}) = x + y + z
//Writing the signature of bounded_int.(+) using Pure
//allows this to work, since the type of (x+y) is not refined
let add3_alt (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) (x + y) z}) = x + y + z
instance bounded_int_u32 : bounded_int FStar.UInt32.t = {
fits = (fun x -> 0 <= x /\ x < 4294967296);
v = (fun x -> FStar.UInt32.v x);
u = FStar.UInt32.uint_to_t;
( + ) = (fun x y -> FStar.UInt32.add x y);
op_Subtraction = (fun x y -> FStar.UInt32.sub x y);
( < ) = FStar.UInt32.(fun x y -> x <^ y);
( <= ) = FStar.UInt32.(fun x y -> x <=^ y);
( % ) = FStar.UInt32.(fun x y -> x %^ y);
properties = ()
}
instance bounded_unsigned_u32 : bounded_unsigned FStar.UInt32.t = {
base = TC.solve;
max_bound = 0xfffffffful;
static_max_bound = true;
properties = ()
}
instance bounded_int_u64 : bounded_int FStar.UInt64.t = {
fits = (fun x -> 0 <= x /\ x <= 0xffffffffffffffff);
v = (fun x -> FStar.UInt64.v x);
u = FStar.UInt64.uint_to_t;
( + ) = (fun x y -> FStar.UInt64.add x y);
op_Subtraction = (fun x y -> FStar.UInt64.sub x y);
( < ) = FStar.UInt64.(fun x y -> x <^ y);
( <= ) = FStar.UInt64.(fun x y -> x <=^ y);
( % ) = FStar.UInt64.(fun x y -> x %^ y);
properties = ()
}
instance bounded_unsigned_u64 : bounded_unsigned FStar.UInt64.t = {
base = TC.solve;
max_bound = 0xffffffffffffffffuL;
static_max_bound = true;
properties = ()
}
let test (t:eqtype) {| _ : bounded_unsigned t |} (x:t) = v x
let add_u32 (x:FStar.UInt32.t) (y:FStar.UInt32.t { ok (+) x y }) = x + y
//Again, parser doesn't allow using (-)
let sub_u32 (x:FStar.UInt32.t) (y:FStar.UInt32.t { ok op_Subtraction x y}) = x - y
//this work and resolved to int, because of the 1
let add_nat_1 (x:nat) = x + 1
//But, to add two nats, this fails, since typeclass resolution doesn't consider subtyping
[@@expect_failure]
let add_nat (x y:nat) = x + y
let nat_as_int (x:nat) : int = x
instance bounded_int_nat : bounded_int nat = {
fits = (fun x -> x >= 0);
v = nat_as_int;
u = (fun x -> x);
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y); //can't write ( - ), it doesn't parse
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
//with an instance for nat this works
let add_nat (x y:nat) = x + y
//but we should find a way to make it work with refinement, otherwise we'll need instances for pos etc. too
let pos_as_int (x:pos) : int = x
instance bounded_int_pos : bounded_int pos = {
fits = (fun x -> x > 0);
v = pos_as_int;
u = (fun x -> x);
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y); //can't write ( - ), it doesn't parse
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
// Using a fits predicate as the bounds check allows this class to also accomodate SizeT
open FStar.SizeT
instance bounded_int_size_t : bounded_int FStar.SizeT.t = {
fits = (fun x -> x >= 0 /\ FStar.SizeT.fits x);
v = (fun x -> FStar.SizeT.v x);
u = (fun x -> FStar.SizeT.uint_to_t x);
( + ) = (fun x y -> FStar.SizeT.add x y);
op_Subtraction = (fun x y -> FStar.SizeT.sub x y);
( < ) = (fun x y -> FStar.SizeT.(x <^ y));
( <= ) = (fun x y -> FStar.SizeT.(x <=^ y));
( % ) = (fun x y -> FStar.SizeT.(x %^ y));
properties = ();
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Lib.BoundedIntegers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.SizeT",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": "TC"
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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 | Pulse.Lib.BoundedIntegers.bounded_unsigned FStar.SizeT.t | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.BoundedIntegers.Mkbounded_unsigned",
"FStar.SizeT.t",
"Pulse.Lib.BoundedIntegers.bounded_int_size_t",
"Pulse.Lib.BoundedIntegers.bounded_int",
"FStar.SizeT.__uint_to_t"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let bounded_unsigned_size_t:bounded_unsigned FStar.SizeT.t =
| { base = TC.solve; max_bound = 0xffffsz; static_max_bound = false; properties = () } | false |
Hacl.Spec.Karatsuba.Lemmas.fst | Hacl.Spec.Karatsuba.Lemmas.lemma_middle_karatsuba | val lemma_middle_karatsuba: a0:nat -> a1:nat -> b0:nat -> b1:nat ->
Lemma
(let s0, t0 = sign_abs a0 a1 in
let s1, t1 = sign_abs b0 b1 in
let t23 = t0 * t1 in
let t01 = a0 * b0 + a1 * b1 in
let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in
t45 == a0 * b1 + a1 * b0) | val lemma_middle_karatsuba: a0:nat -> a1:nat -> b0:nat -> b1:nat ->
Lemma
(let s0, t0 = sign_abs a0 a1 in
let s1, t1 = sign_abs b0 b1 in
let t23 = t0 * t1 in
let t01 = a0 * b0 + a1 * b1 in
let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in
t45 == a0 * b1 + a1 * b0) | let lemma_middle_karatsuba a0 a1 b0 b1 =
let s0, t0 = sign_abs a0 a1 in
let s1, t1 = sign_abs b0 b1 in
let t23 = t0 * t1 in
let t01 = a0 * b0 + a1 * b1 in
let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in
match (s0, s1) with
| (Positive, Positive) ->
calc (==) { //t45
t01 - t23;
(==) { }
a0 * b0 + a1 * b1 - (a0 - a1) * (b0 - b1);
(==) { Math.Lemmas.distributivity_sub_right (a0 - a1) b0 b1 }
a0 * b0 + a1 * b1 - ((a0 - a1) * b0 - (a0 - a1) * b1);
(==) { Math.Lemmas.distributivity_sub_left a0 a1 b0; Math.Lemmas.distributivity_sub_left a0 a1 b1 }
a0 * b0 + a1 * b1 - (a0 * b0 - a1 * b0 - (a0 * b1 - a1 * b1));
(==) { }
a1 * b0 + a0 * b1;
}
| (Negative, Negative) ->
calc (==) { //t45
t01 - t23;
(==) { }
a0 * b0 + a1 * b1 - (a1 - a0) * (b1 - b0);
(==) { Math.Lemmas.distributivity_sub_right (a1 - a0) b1 b0 }
a0 * b0 + a1 * b1 - ((a1 - a0) * b1 - (a1 - a0) * b0);
(==) { Math.Lemmas.distributivity_sub_left a1 a0 b1; Math.Lemmas.distributivity_sub_left a1 a0 b0 }
a0 * b0 + a1 * b1 - (a1 * b1 - a0 * b1 - (a1 * b0 - a0 * b0));
(==) { }
a1 * b0 + a0 * b1;
}
| (Positive, Negative) ->
calc (==) { //t45
t01 + t23;
(==) { }
a0 * b0 + a1 * b1 + (a0 - a1) * (b1 - b0);
(==) { Math.Lemmas.distributivity_sub_right (a0 - a1) b1 b0 }
a0 * b0 + a1 * b1 + ((a0 - a1) * b1 - (a0 - a1) * b0);
(==) { Math.Lemmas.distributivity_sub_left a0 a1 b1; Math.Lemmas.distributivity_sub_left a0 a1 b0 }
a0 * b0 + a1 * b1 + (a0 * b1 - a1 * b1 - (a0 * b0 - a1 * b0));
(==) { }
a1 * b0 + a0 * b1;
}
| (Negative, Positive) ->
calc (==) { //t45
t01 + t23;
(==) { }
a0 * b0 + a1 * b1 + (a1 - a0) * (b0 - b1);
(==) { Math.Lemmas.distributivity_sub_right (a1 - a0) b0 b1 }
a0 * b0 + a1 * b1 + ((a1 - a0) * b0 - (a1 - a0) * b1);
(==) { Math.Lemmas.distributivity_sub_left a1 a0 b0; Math.Lemmas.distributivity_sub_left a1 a0 b1 }
a0 * b0 + a1 * b1 + (a1 * b0 - a0 * b0 - (a1 * b1 - a0 * b1));
(==) { }
a1 * b0 + a0 * b1;
} | {
"file_name": "code/bignum/Hacl.Spec.Karatsuba.Lemmas.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 6,
"end_line": 111,
"start_col": 0,
"start_line": 54
} | module Hacl.Spec.Karatsuba.Lemmas
open FStar.Mul
open Lib.IntTypes
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
type sign =
| Positive
| Negative
let abs (a:nat) (b:nat) : nat =
if a < b then b - a else a - b
val sign_abs: a:nat -> b:nat ->
Pure (tuple2 sign nat)
(requires True)
(ensures fun (s, res) -> res == abs a b /\
s == (if a < b then Negative else Positive))
let sign_abs a b =
if a < b then (Negative, b - a) else (Positive, a - b)
val lemma_double_p: pbits:pos -> aLen:nat{aLen % 2 = 0} ->
Lemma (let p = pow2 (aLen / 2 * pbits) in p * p == pow2 (pbits * aLen))
let lemma_double_p pbits aLen =
let p = pow2 (aLen / 2 * pbits) in
calc (==) {
p * p;
(==) { Math.Lemmas.pow2_plus (aLen / 2 * pbits) (aLen / 2 * pbits) }
pow2 (aLen / 2 * pbits + aLen / 2 * pbits);
(==) { Math.Lemmas.distributivity_add_left (aLen / 2) (aLen / 2) pbits }
pow2 ((aLen / 2 * 2) * pbits);
(==) { Math.Lemmas.lemma_div_exact aLen 2 }
pow2 (aLen * pbits);
}
val lemma_bn_halves: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a:nat{a < pow2 (pbits * aLen)} ->
Lemma (let p = pow2 (aLen / 2 * pbits) in a / p < p /\ a % p < p /\ a == a / p * p + a % p)
let lemma_bn_halves pbits aLen a = lemma_double_p pbits aLen
val lemma_middle_karatsuba: a0:nat -> a1:nat -> b0:nat -> b1:nat ->
Lemma
(let s0, t0 = sign_abs a0 a1 in
let s1, t1 = sign_abs b0 b1 in
let t23 = t0 * t1 in
let t01 = a0 * b0 + a1 * b1 in
let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in
t45 == a0 * b1 + a1 * b0) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Karatsuba.Lemmas.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Karatsuba",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Karatsuba",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a0: Prims.nat -> a1: Prims.nat -> b0: Prims.nat -> b1: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
(let _ = Hacl.Spec.Karatsuba.Lemmas.sign_abs a0 a1 in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ s0 t0 = _ in
let _ = Hacl.Spec.Karatsuba.Lemmas.sign_abs b0 b1 in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ s1 t1 = _ in
let t23 = t0 * t1 in
let t01 = a0 * b0 + a1 * b1 in
let t45 =
(match s0 = s1 with
| true -> t01 - t23
| _ -> t01 + t23)
<:
Prims.int
in
t45 == a0 * b1 + a1 * b0)
<:
Type0)
<:
Type0)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Hacl.Spec.Karatsuba.Lemmas.sign",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"Prims.op_Subtraction",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"FStar.Math.Lemmas.distributivity_sub_right",
"FStar.Math.Lemmas.distributivity_sub_left",
"Prims.op_Equality",
"Prims.bool",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Karatsuba.Lemmas.sign_abs"
] | [] | false | false | true | false | false | let lemma_middle_karatsuba a0 a1 b0 b1 =
| let s0, t0 = sign_abs a0 a1 in
let s1, t1 = sign_abs b0 b1 in
let t23 = t0 * t1 in
let t01 = a0 * b0 + a1 * b1 in
let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in
match (s0, s1) with
| Positive, Positive ->
calc ( == ) {
t01 - t23;
( == ) { () }
a0 * b0 + a1 * b1 - (a0 - a1) * (b0 - b1);
( == ) { Math.Lemmas.distributivity_sub_right (a0 - a1) b0 b1 }
a0 * b0 + a1 * b1 - ((a0 - a1) * b0 - (a0 - a1) * b1);
( == ) { (Math.Lemmas.distributivity_sub_left a0 a1 b0;
Math.Lemmas.distributivity_sub_left a0 a1 b1) }
a0 * b0 + a1 * b1 - (a0 * b0 - a1 * b0 - (a0 * b1 - a1 * b1));
( == ) { () }
a1 * b0 + a0 * b1;
}
| Negative, Negative ->
calc ( == ) {
t01 - t23;
( == ) { () }
a0 * b0 + a1 * b1 - (a1 - a0) * (b1 - b0);
( == ) { Math.Lemmas.distributivity_sub_right (a1 - a0) b1 b0 }
a0 * b0 + a1 * b1 - ((a1 - a0) * b1 - (a1 - a0) * b0);
( == ) { (Math.Lemmas.distributivity_sub_left a1 a0 b1;
Math.Lemmas.distributivity_sub_left a1 a0 b0) }
a0 * b0 + a1 * b1 - (a1 * b1 - a0 * b1 - (a1 * b0 - a0 * b0));
( == ) { () }
a1 * b0 + a0 * b1;
}
| Positive, Negative ->
calc ( == ) {
t01 + t23;
( == ) { () }
a0 * b0 + a1 * b1 + (a0 - a1) * (b1 - b0);
( == ) { Math.Lemmas.distributivity_sub_right (a0 - a1) b1 b0 }
a0 * b0 + a1 * b1 + ((a0 - a1) * b1 - (a0 - a1) * b0);
( == ) { (Math.Lemmas.distributivity_sub_left a0 a1 b1;
Math.Lemmas.distributivity_sub_left a0 a1 b0) }
a0 * b0 + a1 * b1 + (a0 * b1 - a1 * b1 - (a0 * b0 - a1 * b0));
( == ) { () }
a1 * b0 + a0 * b1;
}
| Negative, Positive ->
calc ( == ) {
t01 + t23;
( == ) { () }
a0 * b0 + a1 * b1 + (a1 - a0) * (b0 - b1);
( == ) { Math.Lemmas.distributivity_sub_right (a1 - a0) b0 b1 }
a0 * b0 + a1 * b1 + ((a1 - a0) * b0 - (a1 - a0) * b1);
( == ) { (Math.Lemmas.distributivity_sub_left a1 a0 b0;
Math.Lemmas.distributivity_sub_left a1 a0 b1) }
a0 * b0 + a1 * b1 + (a1 * b0 - a0 * b0 - (a1 * b1 - a0 * b1));
( == ) { () }
a1 * b0 + a0 * b1;
} | false |
Pulse.Lib.BoundedIntegers.fst | Pulse.Lib.BoundedIntegers.size_t_plus_one | val size_t_plus_one : x: FStar.SizeT.t{x < 1024sz} -> FStar.SizeT.t | let size_t_plus_one (x:FStar.SizeT.t { x < 1024sz }) = x + 1sz | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.BoundedIntegers.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 62,
"end_line": 222,
"start_col": 0,
"start_line": 222
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.BoundedIntegers
module TC = FStar.Tactics.Typeclasses
let fits_t (fits:int -> prop) = x:int { fits x }
class bounded_int (t:eqtype) = {
fits: int -> prop;
v : t -> GTot int;
u : fits_t fits -> GTot t;
( + ) : (x:t -> y:t -> Pure t (requires fits (v x + v y)) (ensures fun z -> v z == v x + v y));
op_Subtraction : (x:t -> y:t -> Pure t (requires fits (v x - v y)) (ensures fun z -> v z == v x - v y));
( < ) : (x:t -> y:t -> b:bool { b = (v x < v y)});
( <= ) : (x:t -> y:t -> b:bool { b = (v x <= v y)});
( % ) : (x:t -> y:t -> Pure t (requires v y > 0 /\ fits (v x % v y)) (ensures fun z -> v z == v x % v y));
[@@@TC.no_method]
properties: squash (
(forall (x:t). {:pattern v x} fits (v x))
)
(* ...todo, add other ops **)
}
instance bounded_int_int : bounded_int int = {
fits = (fun _ -> True);
v = id;
u = id;
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y);
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
class bounded_unsigned (t:eqtype) = {
[@@@TC.no_method]
base:bounded_int t;
max_bound:t;
[@@@TC.no_method]
static_max_bound: bool;
[@@@TC.no_method]
properties: squash (
(forall (x:t). v x >= 0 /\ (static_max_bound ==> v x <= v max_bound)) /\
(forall (x:nat). x <= v max_bound ==> fits #t x)
)
}
instance bounded_from_bounded_unsigned (t:eqtype) (c:bounded_unsigned t) : bounded_int t = c.base
let safe_add (#t:eqtype) {| c: bounded_unsigned t |} (x y : t)
: o:option t { Some? o ==> v (Some?.v o) == v x + v y }
= if c.static_max_bound
then (
assert ( x <= max_bound);
if (y <= max_bound - x)
then Some (x + y)
else None
)
else (
if x <= max_bound
then (
assert (fits #t (v (max_bound #t) - v x));
if (y <= max_bound - x)
then Some (x + y)
else None
)
else None
)
let safe_mod (#t:eqtype) {| c: bounded_unsigned t |} (x : t) (y : t)
: Pure (option t)
(requires v y > 0)
(ensures fun o -> Some? o ==> v (Some?.v o) == v x % v y)
= if c.static_max_bound
then Some (x % y)
else (
if y <= max_bound
then (
assert (fits #t (v x % v y));
Some (x % y)
)
else None
)
let ok (#t:eqtype) {| c:bounded_int t |} (op: int -> int -> int) (x y:t) =
c.fits (op (v x) (v y))
let add (#t:eqtype) {| bounded_int t |} (x:t) (y:t { ok (+) x y }) = x + y
let add3 (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) z (x + y)}) = x + y + z
//Writing the signature of bounded_int.(+) using Pure
//allows this to work, since the type of (x+y) is not refined
let add3_alt (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) (x + y) z}) = x + y + z
instance bounded_int_u32 : bounded_int FStar.UInt32.t = {
fits = (fun x -> 0 <= x /\ x < 4294967296);
v = (fun x -> FStar.UInt32.v x);
u = FStar.UInt32.uint_to_t;
( + ) = (fun x y -> FStar.UInt32.add x y);
op_Subtraction = (fun x y -> FStar.UInt32.sub x y);
( < ) = FStar.UInt32.(fun x y -> x <^ y);
( <= ) = FStar.UInt32.(fun x y -> x <=^ y);
( % ) = FStar.UInt32.(fun x y -> x %^ y);
properties = ()
}
instance bounded_unsigned_u32 : bounded_unsigned FStar.UInt32.t = {
base = TC.solve;
max_bound = 0xfffffffful;
static_max_bound = true;
properties = ()
}
instance bounded_int_u64 : bounded_int FStar.UInt64.t = {
fits = (fun x -> 0 <= x /\ x <= 0xffffffffffffffff);
v = (fun x -> FStar.UInt64.v x);
u = FStar.UInt64.uint_to_t;
( + ) = (fun x y -> FStar.UInt64.add x y);
op_Subtraction = (fun x y -> FStar.UInt64.sub x y);
( < ) = FStar.UInt64.(fun x y -> x <^ y);
( <= ) = FStar.UInt64.(fun x y -> x <=^ y);
( % ) = FStar.UInt64.(fun x y -> x %^ y);
properties = ()
}
instance bounded_unsigned_u64 : bounded_unsigned FStar.UInt64.t = {
base = TC.solve;
max_bound = 0xffffffffffffffffuL;
static_max_bound = true;
properties = ()
}
let test (t:eqtype) {| _ : bounded_unsigned t |} (x:t) = v x
let add_u32 (x:FStar.UInt32.t) (y:FStar.UInt32.t { ok (+) x y }) = x + y
//Again, parser doesn't allow using (-)
let sub_u32 (x:FStar.UInt32.t) (y:FStar.UInt32.t { ok op_Subtraction x y}) = x - y
//this work and resolved to int, because of the 1
let add_nat_1 (x:nat) = x + 1
//But, to add two nats, this fails, since typeclass resolution doesn't consider subtyping
[@@expect_failure]
let add_nat (x y:nat) = x + y
let nat_as_int (x:nat) : int = x
instance bounded_int_nat : bounded_int nat = {
fits = (fun x -> x >= 0);
v = nat_as_int;
u = (fun x -> x);
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y); //can't write ( - ), it doesn't parse
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
//with an instance for nat this works
let add_nat (x y:nat) = x + y
//but we should find a way to make it work with refinement, otherwise we'll need instances for pos etc. too
let pos_as_int (x:pos) : int = x
instance bounded_int_pos : bounded_int pos = {
fits = (fun x -> x > 0);
v = pos_as_int;
u = (fun x -> x);
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y); //can't write ( - ), it doesn't parse
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
// Using a fits predicate as the bounds check allows this class to also accomodate SizeT
open FStar.SizeT
instance bounded_int_size_t : bounded_int FStar.SizeT.t = {
fits = (fun x -> x >= 0 /\ FStar.SizeT.fits x);
v = (fun x -> FStar.SizeT.v x);
u = (fun x -> FStar.SizeT.uint_to_t x);
( + ) = (fun x y -> FStar.SizeT.add x y);
op_Subtraction = (fun x y -> FStar.SizeT.sub x y);
( < ) = (fun x y -> FStar.SizeT.(x <^ y));
( <= ) = (fun x y -> FStar.SizeT.(x <=^ y));
( % ) = (fun x y -> FStar.SizeT.(x %^ y));
properties = ();
}
instance bounded_unsigned_size_t : bounded_unsigned FStar.SizeT.t = {
base = TC.solve;
max_bound = 0xffffsz;
static_max_bound = false;
properties = ()
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Lib.BoundedIntegers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.SizeT",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": "TC"
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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: FStar.SizeT.t{x < 1024sz} -> FStar.SizeT.t | Prims.Tot | [
"total"
] | [] | [
"FStar.SizeT.t",
"Prims.b2t",
"Pulse.Lib.BoundedIntegers.op_Less",
"Pulse.Lib.BoundedIntegers.bounded_int_size_t",
"FStar.SizeT.__uint_to_t",
"Pulse.Lib.BoundedIntegers.op_Plus"
] | [] | false | false | false | false | false | let size_t_plus_one (x: FStar.SizeT.t{x < 1024sz}) =
| x + 1sz | false |
|
Vale.AES.GCM_s.fst | Vale.AES.GCM_s.compute_iv_BE_def | val compute_iv_BE_def (h_LE: quad32) (iv: supported_iv_LE) : quad32 | val compute_iv_BE_def (h_LE: quad32) (iv: supported_iv_LE) : quad32 | let compute_iv_BE_def (h_LE:quad32) (iv:supported_iv_LE) : quad32
=
if 8 * (length iv) = 96 then (
let iv_LE = le_bytes_to_quad32 (pad_to_128_bits iv) in
let iv_BE = reverse_bytes_quad32 iv_LE in
let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in
j0_BE
) else (
let padded_iv_quads = le_bytes_to_seq_quad32 (pad_to_128_bits iv) in
let length_BE = insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0 in
let length_LE = reverse_bytes_quad32 length_BE in
let hash_input_LE = append padded_iv_quads (create 1 length_LE) in
let hash_output_LE = ghash_LE h_LE hash_input_LE in
reverse_bytes_quad32 hash_output_LE
) | {
"file_name": "vale/specs/crypto/Vale.AES.GCM_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 34,
"start_col": 0,
"start_line": 20
} | module Vale.AES.GCM_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GHash_s
open FStar.Seq
open FStar.Mul
unfold type gcm_plain_LE = gctr_plain_LE
unfold type gcm_auth_LE = gctr_plain_LE
#reset-options "--z3rlimit 30"
type supported_iv_LE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 } | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GCM_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h_LE: Vale.Def.Types_s.quad32 -> iv: Vale.AES.GCM_s.supported_iv_LE -> Vale.Def.Types_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Types_s.quad32",
"Vale.AES.GCM_s.supported_iv_LE",
"Prims.op_Equality",
"Prims.int",
"FStar.Mul.op_Star",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.nat8",
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.Def.Types_s.le_bytes_to_quad32",
"Vale.AES.GCTR_s.pad_to_128_bits",
"Prims.bool",
"Vale.AES.GHash_s.ghash_LE",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.append",
"FStar.Seq.Base.create",
"Vale.Def.Types_s.insert_nat64_def",
"Vale.Def.Types_s.le_bytes_to_seq_quad32"
] | [] | false | false | false | true | false | let compute_iv_BE_def (h_LE: quad32) (iv: supported_iv_LE) : quad32 =
| if 8 * (length iv) = 96
then
(let iv_LE = le_bytes_to_quad32 (pad_to_128_bits iv) in
let iv_BE = reverse_bytes_quad32 iv_LE in
let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in
j0_BE)
else
(let padded_iv_quads = le_bytes_to_seq_quad32 (pad_to_128_bits iv) in
let length_BE = insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0 in
let length_LE = reverse_bytes_quad32 length_BE in
let hash_input_LE = append padded_iv_quads (create 1 length_LE) in
let hash_output_LE = ghash_LE h_LE hash_input_LE in
reverse_bytes_quad32 hash_output_LE) | false |
Pulse.Lib.BoundedIntegers.fst | Pulse.Lib.BoundedIntegers.bounded_int_nat | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bounded_int_nat:bounded_int nat | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bounded_int_nat:bounded_int nat | instance bounded_int_nat : bounded_int nat = {
fits = (fun x -> x >= 0);
v = nat_as_int;
u = (fun x -> x);
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y); //can't write ( - ), it doesn't parse
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
} | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.BoundedIntegers.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 1,
"end_line": 180,
"start_col": 0,
"start_line": 170
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.BoundedIntegers
module TC = FStar.Tactics.Typeclasses
let fits_t (fits:int -> prop) = x:int { fits x }
class bounded_int (t:eqtype) = {
fits: int -> prop;
v : t -> GTot int;
u : fits_t fits -> GTot t;
( + ) : (x:t -> y:t -> Pure t (requires fits (v x + v y)) (ensures fun z -> v z == v x + v y));
op_Subtraction : (x:t -> y:t -> Pure t (requires fits (v x - v y)) (ensures fun z -> v z == v x - v y));
( < ) : (x:t -> y:t -> b:bool { b = (v x < v y)});
( <= ) : (x:t -> y:t -> b:bool { b = (v x <= v y)});
( % ) : (x:t -> y:t -> Pure t (requires v y > 0 /\ fits (v x % v y)) (ensures fun z -> v z == v x % v y));
[@@@TC.no_method]
properties: squash (
(forall (x:t). {:pattern v x} fits (v x))
)
(* ...todo, add other ops **)
}
instance bounded_int_int : bounded_int int = {
fits = (fun _ -> True);
v = id;
u = id;
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y);
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
class bounded_unsigned (t:eqtype) = {
[@@@TC.no_method]
base:bounded_int t;
max_bound:t;
[@@@TC.no_method]
static_max_bound: bool;
[@@@TC.no_method]
properties: squash (
(forall (x:t). v x >= 0 /\ (static_max_bound ==> v x <= v max_bound)) /\
(forall (x:nat). x <= v max_bound ==> fits #t x)
)
}
instance bounded_from_bounded_unsigned (t:eqtype) (c:bounded_unsigned t) : bounded_int t = c.base
let safe_add (#t:eqtype) {| c: bounded_unsigned t |} (x y : t)
: o:option t { Some? o ==> v (Some?.v o) == v x + v y }
= if c.static_max_bound
then (
assert ( x <= max_bound);
if (y <= max_bound - x)
then Some (x + y)
else None
)
else (
if x <= max_bound
then (
assert (fits #t (v (max_bound #t) - v x));
if (y <= max_bound - x)
then Some (x + y)
else None
)
else None
)
let safe_mod (#t:eqtype) {| c: bounded_unsigned t |} (x : t) (y : t)
: Pure (option t)
(requires v y > 0)
(ensures fun o -> Some? o ==> v (Some?.v o) == v x % v y)
= if c.static_max_bound
then Some (x % y)
else (
if y <= max_bound
then (
assert (fits #t (v x % v y));
Some (x % y)
)
else None
)
let ok (#t:eqtype) {| c:bounded_int t |} (op: int -> int -> int) (x y:t) =
c.fits (op (v x) (v y))
let add (#t:eqtype) {| bounded_int t |} (x:t) (y:t { ok (+) x y }) = x + y
let add3 (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) z (x + y)}) = x + y + z
//Writing the signature of bounded_int.(+) using Pure
//allows this to work, since the type of (x+y) is not refined
let add3_alt (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) (x + y) z}) = x + y + z
instance bounded_int_u32 : bounded_int FStar.UInt32.t = {
fits = (fun x -> 0 <= x /\ x < 4294967296);
v = (fun x -> FStar.UInt32.v x);
u = FStar.UInt32.uint_to_t;
( + ) = (fun x y -> FStar.UInt32.add x y);
op_Subtraction = (fun x y -> FStar.UInt32.sub x y);
( < ) = FStar.UInt32.(fun x y -> x <^ y);
( <= ) = FStar.UInt32.(fun x y -> x <=^ y);
( % ) = FStar.UInt32.(fun x y -> x %^ y);
properties = ()
}
instance bounded_unsigned_u32 : bounded_unsigned FStar.UInt32.t = {
base = TC.solve;
max_bound = 0xfffffffful;
static_max_bound = true;
properties = ()
}
instance bounded_int_u64 : bounded_int FStar.UInt64.t = {
fits = (fun x -> 0 <= x /\ x <= 0xffffffffffffffff);
v = (fun x -> FStar.UInt64.v x);
u = FStar.UInt64.uint_to_t;
( + ) = (fun x y -> FStar.UInt64.add x y);
op_Subtraction = (fun x y -> FStar.UInt64.sub x y);
( < ) = FStar.UInt64.(fun x y -> x <^ y);
( <= ) = FStar.UInt64.(fun x y -> x <=^ y);
( % ) = FStar.UInt64.(fun x y -> x %^ y);
properties = ()
}
instance bounded_unsigned_u64 : bounded_unsigned FStar.UInt64.t = {
base = TC.solve;
max_bound = 0xffffffffffffffffuL;
static_max_bound = true;
properties = ()
}
let test (t:eqtype) {| _ : bounded_unsigned t |} (x:t) = v x
let add_u32 (x:FStar.UInt32.t) (y:FStar.UInt32.t { ok (+) x y }) = x + y
//Again, parser doesn't allow using (-)
let sub_u32 (x:FStar.UInt32.t) (y:FStar.UInt32.t { ok op_Subtraction x y}) = x - y
//this work and resolved to int, because of the 1
let add_nat_1 (x:nat) = x + 1
//But, to add two nats, this fails, since typeclass resolution doesn't consider subtyping
[@@expect_failure]
let add_nat (x y:nat) = x + y
let nat_as_int (x:nat) : int = x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Lib.BoundedIntegers.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": "TC"
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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 | Pulse.Lib.BoundedIntegers.bounded_int Prims.nat | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.BoundedIntegers.Mkbounded_int",
"Pulse.Lib.BoundedIntegers.fits_t",
"Prims.int",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.prop",
"Pulse.Lib.BoundedIntegers.nat_as_int",
"Prims.op_Addition",
"Prims.op_Subtraction",
"Prims.op_LessThan",
"Prims.bool",
"Prims.op_Equality",
"Prims.op_LessThanOrEqual",
"Prims.op_Modulus"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let bounded_int_nat:bounded_int nat =
| {
fits = (fun x -> x >= 0);
v = nat_as_int;
u = (fun x -> x);
( + ) = (fun x y -> Prims.op_Addition x y);
( - ) = (fun x y -> Prims.op_Subtraction x y);
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
} | false |
Spec.Curve25519.fst | Spec.Curve25519.secret_to_public | val secret_to_public: lbytes 32 -> lbytes 32 | val secret_to_public: lbytes 32 -> lbytes 32 | let secret_to_public kpriv =
let basepoint = map secret basepoint_lseq in
scalarmult kpriv basepoint | {
"file_name": "specs/Spec.Curve25519.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 142,
"start_col": 0,
"start_line": 140
} | module Spec.Curve25519
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Curve25519.Lemmas
#set-options "--z3rlimit 30 --ifuel 0 --fuel 0"
(* Field types and parameters *)
let prime : pos = pow2 255 - 19
type elem = x:nat{x < prime}
let zero : elem = 0
let one : elem = 1
let fadd (x:elem) (y:elem) : elem = (x + y) % prime
let fsub (x:elem) (y:elem) : elem = (x - y) % prime
let fmul (x:elem) (y:elem) : elem = (x * y) % prime
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b
let ( **% ) = fpow
let finv (x:elem) : elem = x **% (prime - 2)
let ( /% ) (x:elem) (y:elem) = x *% finv y
(* Type aliases *)
type scalar = lbytes 32
type serialized_point = lbytes 32
type proj_point = elem & elem
let ith_bit (k:scalar) (i:nat{i < 256}) : uint64 =
let q = i / 8 in let r = size (i % 8) in
to_u64 ((k.[q] >>. r) &. u8 1)
let decodeScalar (k:scalar) =
let k : scalar = k.[0] <- (k.[0] &. u8 248) in
let k : scalar = k.[31] <- (k.[31] &. u8 127) in
let k : scalar = k.[31] <- (k.[31] |. u8 64) in k
let decodePoint (u:serialized_point) =
(nat_from_bytes_le u % pow2 255) % prime
let encodePoint (p:proj_point) : Tot serialized_point =
let x, z = p in
let p = x /% z in
nat_to_bytes_le 32 p
let add_and_double q nq nqp1 =
let x_1, z_1 = q in
let x_2, z_2 = nq in
let x_3, z_3 = nqp1 in
let a = x_2 +% z_2 in
let b = x_2 -% z_2 in
let c = x_3 +% z_3 in
let d = x_3 -% z_3 in
let da = d *% a in
let cb = c *% b in
let x_3 = da +% cb in
let z_3 = da -% cb in
let aa = a *% a in
let bb = b *% b in
let x_3 = x_3 *% x_3 in
let z_3 = z_3 *% z_3 in
let e = aa -% bb in
let e121665 = e *% 121665 in
let aa_e121665 = e121665 +% aa in
let x_2 = aa *% bb in
let z_2 = e *% aa_e121665 in
let z_3 = z_3 *% x_1 in
(x_2, z_2), (x_3, z_3)
let double nq =
let x_2, z_2 = nq in
let a = x_2 +% z_2 in
let b = x_2 -% z_2 in
let aa = a *% a in
let bb = b *% b in
let e = aa -% bb in
let e121665 = e *% 121665 in
let aa_e121665 = e121665 +% aa in
let x_2 = aa *% bb in
let z_2 = e *% aa_e121665 in
x_2, z_2
let cswap2 (sw:uint64) (nq:proj_point) (nqp1:proj_point) =
let open Lib.RawIntTypes in
if uint_to_nat sw = 1 then (nqp1, nq) else (nq, nqp1)
let ladder_step (k:scalar) (q:proj_point) (i:nat{i < 251}) (nq, nqp1, swap) =
let bit = ith_bit k (253-i) in
let sw = swap ^. bit in
let nq, nqp1 = cswap2 sw nq nqp1 in
let nq, nqp1 = add_and_double q nq nqp1 in
(nq, nqp1, bit)
let montgomery_ladder (init:elem) (k:scalar) : Tot proj_point =
let q = (init, one) in
let nq = (one, zero) in
let nqp1 = (init, one) in
// bit 255 is 0 and bit 254 is 1
let nq,nqp1 = cswap2 (u64 1) nq nqp1 in
let nq,nqp1 = add_and_double q nq nqp1 in
let swap = u64 1 in
// bits 253-3 depend on scalar
let nq,nqp1,swap = Lib.LoopCombinators.repeati 251 (ladder_step k q) (nq, nqp1, swap) in
let nq,nqp1 = cswap2 swap nq nqp1 in
// bits 2-0 are 0
let nq = double nq in
let nq = double nq in
let nq = double nq in
nq
let scalarmult (k:scalar) (u:serialized_point) : Tot serialized_point =
let u = decodePoint u in
let res = montgomery_ladder u k in
encodePoint res
inline_for_extraction
let basepoint_list : x:list byte_t{List.Tot.length x == 32} =
[@inline_let]
let l =
[9uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy;
0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy;
0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy;
0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy] in
assert_norm (List.Tot.length l == 32);
l
let basepoint_lseq : Lib.Sequence.lseq byte_t 32 =
Lib.Sequence.of_list basepoint_list | {
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Curve25519.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Curve25519.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | kpriv: Lib.ByteSequence.lbytes 32 -> Lib.ByteSequence.lbytes 32 | Prims.Tot | [
"total"
] | [] | [
"Lib.ByteSequence.lbytes",
"Spec.Curve25519.scalarmult",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.eq2",
"Lib.Sequence.index",
"Lib.IntTypes.secret",
"Lib.IntTypes.PUB",
"Spec.Curve25519.basepoint_lseq",
"Lib.Sequence.map",
"Lib.IntTypes.uint_t"
] | [] | false | false | false | false | false | let secret_to_public kpriv =
| let basepoint = map secret basepoint_lseq in
scalarmult kpriv basepoint | false |
Hacl.Spec.Karatsuba.Lemmas.fst | Hacl.Spec.Karatsuba.Lemmas.karatsuba | val karatsuba:
pbits:pos // pbits = bits t
-> aLen:nat
-> a:nat{a < pow2 (pbits * aLen)}
-> b:nat{b < pow2 (pbits * aLen)} ->
Tot (res:nat{res == a * b}) (decreases aLen) | val karatsuba:
pbits:pos // pbits = bits t
-> aLen:nat
-> a:nat{a < pow2 (pbits * aLen)}
-> b:nat{b < pow2 (pbits * aLen)} ->
Tot (res:nat{res == a * b}) (decreases aLen) | let rec karatsuba pbits aLen a b =
if aLen < 16 || aLen % 2 = 1 then a * b
else begin
let aLen2 = aLen / 2 in
let p = pow2 (aLen2 * pbits) in
let a0 = a % p in let a1 = a / p in
let b0 = b % p in let b1 = b / p in
lemma_bn_halves pbits aLen a;
lemma_bn_halves pbits aLen b;
let s0, t0 = sign_abs a0 a1 in
let s1, t1 = sign_abs b0 b1 in
let t23 = karatsuba pbits aLen2 t0 t1 in assert (t23 == t0 * t1);
let r01 = karatsuba pbits aLen2 a0 b0 in assert (r01 == a0 * b0);
let r23 = karatsuba pbits aLen2 a1 b1 in assert (r23 == a1 * b1);
let t01 = r01 + r23 in assert (t01 == a0 * b0 + a1 * b1);
let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in
lemma_middle_karatsuba a0 a1 b0 b1;
assert (t45 == a0 * b1 + a1 * b0);
let res = r23 * pow2 (pbits * aLen) + t45 * p + r01 in
lemma_karatsuba pbits aLen a0 a1 b0 b1;
res end | {
"file_name": "code/bignum/Hacl.Spec.Karatsuba.Lemmas.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 185,
"start_col": 0,
"start_line": 160
} | module Hacl.Spec.Karatsuba.Lemmas
open FStar.Mul
open Lib.IntTypes
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
type sign =
| Positive
| Negative
let abs (a:nat) (b:nat) : nat =
if a < b then b - a else a - b
val sign_abs: a:nat -> b:nat ->
Pure (tuple2 sign nat)
(requires True)
(ensures fun (s, res) -> res == abs a b /\
s == (if a < b then Negative else Positive))
let sign_abs a b =
if a < b then (Negative, b - a) else (Positive, a - b)
val lemma_double_p: pbits:pos -> aLen:nat{aLen % 2 = 0} ->
Lemma (let p = pow2 (aLen / 2 * pbits) in p * p == pow2 (pbits * aLen))
let lemma_double_p pbits aLen =
let p = pow2 (aLen / 2 * pbits) in
calc (==) {
p * p;
(==) { Math.Lemmas.pow2_plus (aLen / 2 * pbits) (aLen / 2 * pbits) }
pow2 (aLen / 2 * pbits + aLen / 2 * pbits);
(==) { Math.Lemmas.distributivity_add_left (aLen / 2) (aLen / 2) pbits }
pow2 ((aLen / 2 * 2) * pbits);
(==) { Math.Lemmas.lemma_div_exact aLen 2 }
pow2 (aLen * pbits);
}
val lemma_bn_halves: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a:nat{a < pow2 (pbits * aLen)} ->
Lemma (let p = pow2 (aLen / 2 * pbits) in a / p < p /\ a % p < p /\ a == a / p * p + a % p)
let lemma_bn_halves pbits aLen a = lemma_double_p pbits aLen
val lemma_middle_karatsuba: a0:nat -> a1:nat -> b0:nat -> b1:nat ->
Lemma
(let s0, t0 = sign_abs a0 a1 in
let s1, t1 = sign_abs b0 b1 in
let t23 = t0 * t1 in
let t01 = a0 * b0 + a1 * b1 in
let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in
t45 == a0 * b1 + a1 * b0)
let lemma_middle_karatsuba a0 a1 b0 b1 =
let s0, t0 = sign_abs a0 a1 in
let s1, t1 = sign_abs b0 b1 in
let t23 = t0 * t1 in
let t01 = a0 * b0 + a1 * b1 in
let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in
match (s0, s1) with
| (Positive, Positive) ->
calc (==) { //t45
t01 - t23;
(==) { }
a0 * b0 + a1 * b1 - (a0 - a1) * (b0 - b1);
(==) { Math.Lemmas.distributivity_sub_right (a0 - a1) b0 b1 }
a0 * b0 + a1 * b1 - ((a0 - a1) * b0 - (a0 - a1) * b1);
(==) { Math.Lemmas.distributivity_sub_left a0 a1 b0; Math.Lemmas.distributivity_sub_left a0 a1 b1 }
a0 * b0 + a1 * b1 - (a0 * b0 - a1 * b0 - (a0 * b1 - a1 * b1));
(==) { }
a1 * b0 + a0 * b1;
}
| (Negative, Negative) ->
calc (==) { //t45
t01 - t23;
(==) { }
a0 * b0 + a1 * b1 - (a1 - a0) * (b1 - b0);
(==) { Math.Lemmas.distributivity_sub_right (a1 - a0) b1 b0 }
a0 * b0 + a1 * b1 - ((a1 - a0) * b1 - (a1 - a0) * b0);
(==) { Math.Lemmas.distributivity_sub_left a1 a0 b1; Math.Lemmas.distributivity_sub_left a1 a0 b0 }
a0 * b0 + a1 * b1 - (a1 * b1 - a0 * b1 - (a1 * b0 - a0 * b0));
(==) { }
a1 * b0 + a0 * b1;
}
| (Positive, Negative) ->
calc (==) { //t45
t01 + t23;
(==) { }
a0 * b0 + a1 * b1 + (a0 - a1) * (b1 - b0);
(==) { Math.Lemmas.distributivity_sub_right (a0 - a1) b1 b0 }
a0 * b0 + a1 * b1 + ((a0 - a1) * b1 - (a0 - a1) * b0);
(==) { Math.Lemmas.distributivity_sub_left a0 a1 b1; Math.Lemmas.distributivity_sub_left a0 a1 b0 }
a0 * b0 + a1 * b1 + (a0 * b1 - a1 * b1 - (a0 * b0 - a1 * b0));
(==) { }
a1 * b0 + a0 * b1;
}
| (Negative, Positive) ->
calc (==) { //t45
t01 + t23;
(==) { }
a0 * b0 + a1 * b1 + (a1 - a0) * (b0 - b1);
(==) { Math.Lemmas.distributivity_sub_right (a1 - a0) b0 b1 }
a0 * b0 + a1 * b1 + ((a1 - a0) * b0 - (a1 - a0) * b1);
(==) { Math.Lemmas.distributivity_sub_left a1 a0 b0; Math.Lemmas.distributivity_sub_left a1 a0 b1 }
a0 * b0 + a1 * b1 + (a1 * b0 - a0 * b0 - (a1 * b1 - a0 * b1));
(==) { }
a1 * b0 + a0 * b1;
}
val lemma_karatsuba: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a0:nat -> a1:nat -> b0:nat -> b1:nat -> Lemma
(let aLen2 = aLen / 2 in
let p = pow2 (pbits * aLen2) in
let a = a1 * p + a0 in
let b = b1 * p + b0 in
a1 * b1 * pow2 (pbits * aLen) + (a0 * b1 + a1 * b0) * p + a0 * b0 == a * b)
#push-options "--z3rlimit 200"
let lemma_karatsuba pbits aLen a0 a1 b0 b1 =
let aLen2 = aLen / 2 in
let p = pow2 (pbits * aLen2) in
let a = a1 * p + a0 in
let b = b1 * p + b0 in
calc (==) {
a * b;
(==) { }
(a1 * p + a0) * (b1 * p + b0);
(==) { Math.Lemmas.distributivity_add_left (a1 * p) a0 (b1 * p + b0) }
a1 * p * (b1 * p + b0) + a0 * (b1 * p + b0);
(==) { Math.Lemmas.distributivity_add_right (a1 * p) (b1 * p) b0; Math.Lemmas.distributivity_add_right a0 (b1 * p) b0 }
a1 * p * (b1 * p) + a1 * p * b0 + a0 * (b1 * p) + a0 * b0;
(==) { Math.Lemmas.paren_mul_right a0 b1 p }
a1 * p * (b1 * p) + a1 * p * b0 + a0 * b1 * p + a0 * b0;
(==) {
Math.Lemmas.paren_mul_right a1 p (b1 * p); Math.Lemmas.swap_mul b1 p;
Math.Lemmas.paren_mul_right p p b1; Math.Lemmas.swap_mul b1 (p * p) }
a1 * (b1 * (p * p)) + a1 * p * b0 + a0 * b1 * p + a0 * b0;
(==) { Math.Lemmas.paren_mul_right a1 b1 (p * p) }
a1 * b1 * (p * p) + a1 * p * b0 + a0 * b1 * p + a0 * b0;
(==) { lemma_double_p pbits aLen }
a1 * b1 * pow2 (pbits * aLen) + a1 * p * b0 + a0 * b1 * p + a0 * b0;
(==) { Math.Lemmas.paren_mul_right a1 p b0; Math.Lemmas.swap_mul b0 p; Math.Lemmas.paren_mul_right a1 b0 p }
a1 * b1 * pow2 (pbits * aLen) + a1 * b0 * p + a0 * b1 * p + a0 * b0;
(==) { Math.Lemmas.distributivity_add_left (a1 * b0) (a0 * b1) p }
a1 * b1 * pow2 (pbits * aLen) + (a1 * b0 + a0 * b1) * p + a0 * b0;
}
#pop-options
val karatsuba:
pbits:pos // pbits = bits t
-> aLen:nat
-> a:nat{a < pow2 (pbits * aLen)}
-> b:nat{b < pow2 (pbits * aLen)} ->
Tot (res:nat{res == a * b}) (decreases aLen) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Karatsuba.Lemmas.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Karatsuba",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Karatsuba",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
pbits: Prims.pos ->
aLen: Prims.nat ->
a: Prims.nat{a < Prims.pow2 (pbits * aLen)} ->
b: Prims.nat{b < Prims.pow2 (pbits * aLen)}
-> Prims.Tot (res: Prims.nat{res == a * b}) | Prims.Tot | [
"total",
""
] | [] | [
"Prims.pos",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Mul.op_Star",
"Prims.op_BarBar",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Prims.bool",
"Hacl.Spec.Karatsuba.Lemmas.sign",
"Prims.unit",
"Hacl.Spec.Karatsuba.Lemmas.lemma_karatsuba",
"Prims.op_Addition",
"Prims._assert",
"Prims.eq2",
"Hacl.Spec.Karatsuba.Lemmas.lemma_middle_karatsuba",
"Prims.op_Subtraction",
"Prims.op_Multiply",
"Hacl.Spec.Karatsuba.Lemmas.karatsuba",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Karatsuba.Lemmas.sign_abs",
"Hacl.Spec.Karatsuba.Lemmas.lemma_bn_halves",
"Prims.op_Division"
] | [
"recursion"
] | false | false | false | false | false | let rec karatsuba pbits aLen a b =
| if aLen < 16 || aLen % 2 = 1
then a * b
else
let aLen2 = aLen / 2 in
let p = pow2 (aLen2 * pbits) in
let a0 = a % p in
let a1 = a / p in
let b0 = b % p in
let b1 = b / p in
lemma_bn_halves pbits aLen a;
lemma_bn_halves pbits aLen b;
let s0, t0 = sign_abs a0 a1 in
let s1, t1 = sign_abs b0 b1 in
let t23 = karatsuba pbits aLen2 t0 t1 in
assert (t23 == t0 * t1);
let r01 = karatsuba pbits aLen2 a0 b0 in
assert (r01 == a0 * b0);
let r23 = karatsuba pbits aLen2 a1 b1 in
assert (r23 == a1 * b1);
let t01 = r01 + r23 in
assert (t01 == a0 * b0 + a1 * b1);
let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in
lemma_middle_karatsuba a0 a1 b0 b1;
assert (t45 == a0 * b1 + a1 * b0);
let res = r23 * pow2 (pbits * aLen) + t45 * p + r01 in
lemma_karatsuba pbits aLen a0 a1 b0 b1;
res | false |
Pulse.Lib.BoundedIntegers.fst | Pulse.Lib.BoundedIntegers.add_u32 | val add_u32 : x: FStar.UInt32.t ->
y: FStar.UInt32.t{Pulse.Lib.BoundedIntegers.ok Pulse.Lib.BoundedIntegers.op_Plus x y}
-> FStar.UInt32.t | let add_u32 (x:FStar.UInt32.t) (y:FStar.UInt32.t { ok (+) x y }) = x + y | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.BoundedIntegers.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 72,
"end_line": 156,
"start_col": 0,
"start_line": 156
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.BoundedIntegers
module TC = FStar.Tactics.Typeclasses
let fits_t (fits:int -> prop) = x:int { fits x }
class bounded_int (t:eqtype) = {
fits: int -> prop;
v : t -> GTot int;
u : fits_t fits -> GTot t;
( + ) : (x:t -> y:t -> Pure t (requires fits (v x + v y)) (ensures fun z -> v z == v x + v y));
op_Subtraction : (x:t -> y:t -> Pure t (requires fits (v x - v y)) (ensures fun z -> v z == v x - v y));
( < ) : (x:t -> y:t -> b:bool { b = (v x < v y)});
( <= ) : (x:t -> y:t -> b:bool { b = (v x <= v y)});
( % ) : (x:t -> y:t -> Pure t (requires v y > 0 /\ fits (v x % v y)) (ensures fun z -> v z == v x % v y));
[@@@TC.no_method]
properties: squash (
(forall (x:t). {:pattern v x} fits (v x))
)
(* ...todo, add other ops **)
}
instance bounded_int_int : bounded_int int = {
fits = (fun _ -> True);
v = id;
u = id;
( + ) = (fun x y -> Prims.op_Addition x y);
op_Subtraction = (fun x y -> Prims.op_Subtraction x y);
( < ) = (fun x y -> Prims.op_LessThan x y);
( <= ) = (fun x y -> Prims.op_LessThanOrEqual x y);
( % ) = (fun x y -> Prims.op_Modulus x y);
properties = ()
}
class bounded_unsigned (t:eqtype) = {
[@@@TC.no_method]
base:bounded_int t;
max_bound:t;
[@@@TC.no_method]
static_max_bound: bool;
[@@@TC.no_method]
properties: squash (
(forall (x:t). v x >= 0 /\ (static_max_bound ==> v x <= v max_bound)) /\
(forall (x:nat). x <= v max_bound ==> fits #t x)
)
}
instance bounded_from_bounded_unsigned (t:eqtype) (c:bounded_unsigned t) : bounded_int t = c.base
let safe_add (#t:eqtype) {| c: bounded_unsigned t |} (x y : t)
: o:option t { Some? o ==> v (Some?.v o) == v x + v y }
= if c.static_max_bound
then (
assert ( x <= max_bound);
if (y <= max_bound - x)
then Some (x + y)
else None
)
else (
if x <= max_bound
then (
assert (fits #t (v (max_bound #t) - v x));
if (y <= max_bound - x)
then Some (x + y)
else None
)
else None
)
let safe_mod (#t:eqtype) {| c: bounded_unsigned t |} (x : t) (y : t)
: Pure (option t)
(requires v y > 0)
(ensures fun o -> Some? o ==> v (Some?.v o) == v x % v y)
= if c.static_max_bound
then Some (x % y)
else (
if y <= max_bound
then (
assert (fits #t (v x % v y));
Some (x % y)
)
else None
)
let ok (#t:eqtype) {| c:bounded_int t |} (op: int -> int -> int) (x y:t) =
c.fits (op (v x) (v y))
let add (#t:eqtype) {| bounded_int t |} (x:t) (y:t { ok (+) x y }) = x + y
let add3 (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) z (x + y)}) = x + y + z
//Writing the signature of bounded_int.(+) using Pure
//allows this to work, since the type of (x+y) is not refined
let add3_alt (#t:eqtype) {| bounded_int t |} (x:t) (y:t) (z:t { ok (+) x y /\ ok (+) (x + y) z}) = x + y + z
instance bounded_int_u32 : bounded_int FStar.UInt32.t = {
fits = (fun x -> 0 <= x /\ x < 4294967296);
v = (fun x -> FStar.UInt32.v x);
u = FStar.UInt32.uint_to_t;
( + ) = (fun x y -> FStar.UInt32.add x y);
op_Subtraction = (fun x y -> FStar.UInt32.sub x y);
( < ) = FStar.UInt32.(fun x y -> x <^ y);
( <= ) = FStar.UInt32.(fun x y -> x <=^ y);
( % ) = FStar.UInt32.(fun x y -> x %^ y);
properties = ()
}
instance bounded_unsigned_u32 : bounded_unsigned FStar.UInt32.t = {
base = TC.solve;
max_bound = 0xfffffffful;
static_max_bound = true;
properties = ()
}
instance bounded_int_u64 : bounded_int FStar.UInt64.t = {
fits = (fun x -> 0 <= x /\ x <= 0xffffffffffffffff);
v = (fun x -> FStar.UInt64.v x);
u = FStar.UInt64.uint_to_t;
( + ) = (fun x y -> FStar.UInt64.add x y);
op_Subtraction = (fun x y -> FStar.UInt64.sub x y);
( < ) = FStar.UInt64.(fun x y -> x <^ y);
( <= ) = FStar.UInt64.(fun x y -> x <=^ y);
( % ) = FStar.UInt64.(fun x y -> x %^ y);
properties = ()
}
instance bounded_unsigned_u64 : bounded_unsigned FStar.UInt64.t = {
base = TC.solve;
max_bound = 0xffffffffffffffffuL;
static_max_bound = true;
properties = ()
}
let test (t:eqtype) {| _ : bounded_unsigned t |} (x:t) = v x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Lib.BoundedIntegers.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": "TC"
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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: FStar.UInt32.t ->
y: FStar.UInt32.t{Pulse.Lib.BoundedIntegers.ok Pulse.Lib.BoundedIntegers.op_Plus x y}
-> FStar.UInt32.t | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"Pulse.Lib.BoundedIntegers.ok",
"Pulse.Lib.BoundedIntegers.bounded_int_u32",
"Pulse.Lib.BoundedIntegers.op_Plus",
"Prims.int",
"Pulse.Lib.BoundedIntegers.bounded_int_int"
] | [] | false | false | false | false | false | let add_u32 (x: FStar.UInt32.t) (y: FStar.UInt32.t{ok ( + ) x y}) =
| x + y | false |
|
Hacl.Spec.Karatsuba.Lemmas.fst | Hacl.Spec.Karatsuba.Lemmas.lemma_karatsuba | val lemma_karatsuba: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a0:nat -> a1:nat -> b0:nat -> b1:nat -> Lemma
(let aLen2 = aLen / 2 in
let p = pow2 (pbits * aLen2) in
let a = a1 * p + a0 in
let b = b1 * p + b0 in
a1 * b1 * pow2 (pbits * aLen) + (a0 * b1 + a1 * b0) * p + a0 * b0 == a * b) | val lemma_karatsuba: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a0:nat -> a1:nat -> b0:nat -> b1:nat -> Lemma
(let aLen2 = aLen / 2 in
let p = pow2 (pbits * aLen2) in
let a = a1 * p + a0 in
let b = b1 * p + b0 in
a1 * b1 * pow2 (pbits * aLen) + (a0 * b1 + a1 * b0) * p + a0 * b0 == a * b) | let lemma_karatsuba pbits aLen a0 a1 b0 b1 =
let aLen2 = aLen / 2 in
let p = pow2 (pbits * aLen2) in
let a = a1 * p + a0 in
let b = b1 * p + b0 in
calc (==) {
a * b;
(==) { }
(a1 * p + a0) * (b1 * p + b0);
(==) { Math.Lemmas.distributivity_add_left (a1 * p) a0 (b1 * p + b0) }
a1 * p * (b1 * p + b0) + a0 * (b1 * p + b0);
(==) { Math.Lemmas.distributivity_add_right (a1 * p) (b1 * p) b0; Math.Lemmas.distributivity_add_right a0 (b1 * p) b0 }
a1 * p * (b1 * p) + a1 * p * b0 + a0 * (b1 * p) + a0 * b0;
(==) { Math.Lemmas.paren_mul_right a0 b1 p }
a1 * p * (b1 * p) + a1 * p * b0 + a0 * b1 * p + a0 * b0;
(==) {
Math.Lemmas.paren_mul_right a1 p (b1 * p); Math.Lemmas.swap_mul b1 p;
Math.Lemmas.paren_mul_right p p b1; Math.Lemmas.swap_mul b1 (p * p) }
a1 * (b1 * (p * p)) + a1 * p * b0 + a0 * b1 * p + a0 * b0;
(==) { Math.Lemmas.paren_mul_right a1 b1 (p * p) }
a1 * b1 * (p * p) + a1 * p * b0 + a0 * b1 * p + a0 * b0;
(==) { lemma_double_p pbits aLen }
a1 * b1 * pow2 (pbits * aLen) + a1 * p * b0 + a0 * b1 * p + a0 * b0;
(==) { Math.Lemmas.paren_mul_right a1 p b0; Math.Lemmas.swap_mul b0 p; Math.Lemmas.paren_mul_right a1 b0 p }
a1 * b1 * pow2 (pbits * aLen) + a1 * b0 * p + a0 * b1 * p + a0 * b0;
(==) { Math.Lemmas.distributivity_add_left (a1 * b0) (a0 * b1) p }
a1 * b1 * pow2 (pbits * aLen) + (a1 * b0 + a0 * b1) * p + a0 * b0;
} | {
"file_name": "code/bignum/Hacl.Spec.Karatsuba.Lemmas.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 150,
"start_col": 0,
"start_line": 122
} | module Hacl.Spec.Karatsuba.Lemmas
open FStar.Mul
open Lib.IntTypes
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
type sign =
| Positive
| Negative
let abs (a:nat) (b:nat) : nat =
if a < b then b - a else a - b
val sign_abs: a:nat -> b:nat ->
Pure (tuple2 sign nat)
(requires True)
(ensures fun (s, res) -> res == abs a b /\
s == (if a < b then Negative else Positive))
let sign_abs a b =
if a < b then (Negative, b - a) else (Positive, a - b)
val lemma_double_p: pbits:pos -> aLen:nat{aLen % 2 = 0} ->
Lemma (let p = pow2 (aLen / 2 * pbits) in p * p == pow2 (pbits * aLen))
let lemma_double_p pbits aLen =
let p = pow2 (aLen / 2 * pbits) in
calc (==) {
p * p;
(==) { Math.Lemmas.pow2_plus (aLen / 2 * pbits) (aLen / 2 * pbits) }
pow2 (aLen / 2 * pbits + aLen / 2 * pbits);
(==) { Math.Lemmas.distributivity_add_left (aLen / 2) (aLen / 2) pbits }
pow2 ((aLen / 2 * 2) * pbits);
(==) { Math.Lemmas.lemma_div_exact aLen 2 }
pow2 (aLen * pbits);
}
val lemma_bn_halves: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a:nat{a < pow2 (pbits * aLen)} ->
Lemma (let p = pow2 (aLen / 2 * pbits) in a / p < p /\ a % p < p /\ a == a / p * p + a % p)
let lemma_bn_halves pbits aLen a = lemma_double_p pbits aLen
val lemma_middle_karatsuba: a0:nat -> a1:nat -> b0:nat -> b1:nat ->
Lemma
(let s0, t0 = sign_abs a0 a1 in
let s1, t1 = sign_abs b0 b1 in
let t23 = t0 * t1 in
let t01 = a0 * b0 + a1 * b1 in
let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in
t45 == a0 * b1 + a1 * b0)
let lemma_middle_karatsuba a0 a1 b0 b1 =
let s0, t0 = sign_abs a0 a1 in
let s1, t1 = sign_abs b0 b1 in
let t23 = t0 * t1 in
let t01 = a0 * b0 + a1 * b1 in
let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in
match (s0, s1) with
| (Positive, Positive) ->
calc (==) { //t45
t01 - t23;
(==) { }
a0 * b0 + a1 * b1 - (a0 - a1) * (b0 - b1);
(==) { Math.Lemmas.distributivity_sub_right (a0 - a1) b0 b1 }
a0 * b0 + a1 * b1 - ((a0 - a1) * b0 - (a0 - a1) * b1);
(==) { Math.Lemmas.distributivity_sub_left a0 a1 b0; Math.Lemmas.distributivity_sub_left a0 a1 b1 }
a0 * b0 + a1 * b1 - (a0 * b0 - a1 * b0 - (a0 * b1 - a1 * b1));
(==) { }
a1 * b0 + a0 * b1;
}
| (Negative, Negative) ->
calc (==) { //t45
t01 - t23;
(==) { }
a0 * b0 + a1 * b1 - (a1 - a0) * (b1 - b0);
(==) { Math.Lemmas.distributivity_sub_right (a1 - a0) b1 b0 }
a0 * b0 + a1 * b1 - ((a1 - a0) * b1 - (a1 - a0) * b0);
(==) { Math.Lemmas.distributivity_sub_left a1 a0 b1; Math.Lemmas.distributivity_sub_left a1 a0 b0 }
a0 * b0 + a1 * b1 - (a1 * b1 - a0 * b1 - (a1 * b0 - a0 * b0));
(==) { }
a1 * b0 + a0 * b1;
}
| (Positive, Negative) ->
calc (==) { //t45
t01 + t23;
(==) { }
a0 * b0 + a1 * b1 + (a0 - a1) * (b1 - b0);
(==) { Math.Lemmas.distributivity_sub_right (a0 - a1) b1 b0 }
a0 * b0 + a1 * b1 + ((a0 - a1) * b1 - (a0 - a1) * b0);
(==) { Math.Lemmas.distributivity_sub_left a0 a1 b1; Math.Lemmas.distributivity_sub_left a0 a1 b0 }
a0 * b0 + a1 * b1 + (a0 * b1 - a1 * b1 - (a0 * b0 - a1 * b0));
(==) { }
a1 * b0 + a0 * b1;
}
| (Negative, Positive) ->
calc (==) { //t45
t01 + t23;
(==) { }
a0 * b0 + a1 * b1 + (a1 - a0) * (b0 - b1);
(==) { Math.Lemmas.distributivity_sub_right (a1 - a0) b0 b1 }
a0 * b0 + a1 * b1 + ((a1 - a0) * b0 - (a1 - a0) * b1);
(==) { Math.Lemmas.distributivity_sub_left a1 a0 b0; Math.Lemmas.distributivity_sub_left a1 a0 b1 }
a0 * b0 + a1 * b1 + (a1 * b0 - a0 * b0 - (a1 * b1 - a0 * b1));
(==) { }
a1 * b0 + a0 * b1;
}
val lemma_karatsuba: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a0:nat -> a1:nat -> b0:nat -> b1:nat -> Lemma
(let aLen2 = aLen / 2 in
let p = pow2 (pbits * aLen2) in
let a = a1 * p + a0 in
let b = b1 * p + b0 in
a1 * b1 * pow2 (pbits * aLen) + (a0 * b1 + a1 * b0) * p + a0 * b0 == a * b) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Karatsuba.Lemmas.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Karatsuba",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Karatsuba",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
pbits: Prims.pos ->
aLen: Prims.nat{aLen % 2 = 0} ->
a0: Prims.nat ->
a1: Prims.nat ->
b0: Prims.nat ->
b1: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
(let aLen2 = aLen / 2 in
let p = Prims.pow2 (pbits * aLen2) in
let a = a1 * p + a0 in
let b = b1 * p + b0 in
(a1 * b1) * Prims.pow2 (pbits * aLen) + (a0 * b1 + a1 * b0) * p + a0 * b0 == a * b)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.pos",
"Prims.nat",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"FStar.Calc.calc_finish",
"Prims.eq2",
"FStar.Mul.op_Star",
"Prims.op_Addition",
"Prims.pow2",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"FStar.Math.Lemmas.distributivity_add_left",
"FStar.Math.Lemmas.distributivity_add_right",
"FStar.Math.Lemmas.paren_mul_right",
"FStar.Math.Lemmas.swap_mul",
"Hacl.Spec.Karatsuba.Lemmas.lemma_double_p",
"Prims.op_Division"
] | [] | false | false | true | false | false | let lemma_karatsuba pbits aLen a0 a1 b0 b1 =
| let aLen2 = aLen / 2 in
let p = pow2 (pbits * aLen2) in
let a = a1 * p + a0 in
let b = b1 * p + b0 in
calc ( == ) {
a * b;
( == ) { () }
(a1 * p + a0) * (b1 * p + b0);
( == ) { Math.Lemmas.distributivity_add_left (a1 * p) a0 (b1 * p + b0) }
(a1 * p) * (b1 * p + b0) + a0 * (b1 * p + b0);
( == ) { (Math.Lemmas.distributivity_add_right (a1 * p) (b1 * p) b0;
Math.Lemmas.distributivity_add_right a0 (b1 * p) b0) }
(a1 * p) * (b1 * p) + (a1 * p) * b0 + a0 * (b1 * p) + a0 * b0;
( == ) { Math.Lemmas.paren_mul_right a0 b1 p }
(a1 * p) * (b1 * p) + (a1 * p) * b0 + (a0 * b1) * p + a0 * b0;
( == ) { (Math.Lemmas.paren_mul_right a1 p (b1 * p);
Math.Lemmas.swap_mul b1 p;
Math.Lemmas.paren_mul_right p p b1;
Math.Lemmas.swap_mul b1 (p * p)) }
a1 * (b1 * (p * p)) + (a1 * p) * b0 + (a0 * b1) * p + a0 * b0;
( == ) { Math.Lemmas.paren_mul_right a1 b1 (p * p) }
(a1 * b1) * (p * p) + (a1 * p) * b0 + (a0 * b1) * p + a0 * b0;
( == ) { lemma_double_p pbits aLen }
(a1 * b1) * pow2 (pbits * aLen) + (a1 * p) * b0 + (a0 * b1) * p + a0 * b0;
( == ) { (Math.Lemmas.paren_mul_right a1 p b0;
Math.Lemmas.swap_mul b0 p;
Math.Lemmas.paren_mul_right a1 b0 p) }
(a1 * b1) * pow2 (pbits * aLen) + (a1 * b0) * p + (a0 * b1) * p + a0 * b0;
( == ) { Math.Lemmas.distributivity_add_left (a1 * b0) (a0 * b1) p }
(a1 * b1) * pow2 (pbits * aLen) + (a1 * b0 + a0 * b1) * p + a0 * b0;
} | false |
Vale.AES.GCM_s.fst | Vale.AES.GCM_s.gcm_encrypt_LE_def | val gcm_encrypt_LE_def (alg: algorithm) (key: seq nat8) (iv: supported_iv_LE) (plain auth: seq nat8)
: Pure (seq nat8 & seq nat8)
(requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32)
(ensures fun (c, t) -> True) | val gcm_encrypt_LE_def (alg: algorithm) (key: seq nat8) (iv: supported_iv_LE) (plain auth: seq nat8)
: Pure (seq nat8 & seq nat8)
(requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32)
(ensures fun (c, t) -> True) | let gcm_encrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (plain:seq nat8) (auth:seq nat8) :
Pure (seq nat8 & seq nat8)
(requires
is_aes_key alg key /\
length plain < pow2_32 /\
length auth < pow2_32
)
(ensures fun (c, t) -> True)
=
let key_LE = seq_nat8_to_seq_nat32_LE key in
let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_LE iv in
let c = gctr_encrypt_LE (inc32 j0_BE 1) plain alg key_LE in
// Sets the first 64-bit number to 8 * length plain, and the second to 8* length auth
let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0 in
let lengths_LE = reverse_bytes_quad32 lengths_BE in
let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits c) in
let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in
let s_LE = ghash_LE h_LE hash_input_LE in
let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in
(c, t) | {
"file_name": "vale/specs/crypto/Vale.AES.GCM_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 8,
"end_line": 65,
"start_col": 0,
"start_line": 39
} | module Vale.AES.GCM_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GHash_s
open FStar.Seq
open FStar.Mul
unfold type gcm_plain_LE = gctr_plain_LE
unfold type gcm_auth_LE = gctr_plain_LE
#reset-options "--z3rlimit 30"
type supported_iv_LE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 }
let compute_iv_BE_def (h_LE:quad32) (iv:supported_iv_LE) : quad32
=
if 8 * (length iv) = 96 then (
let iv_LE = le_bytes_to_quad32 (pad_to_128_bits iv) in
let iv_BE = reverse_bytes_quad32 iv_LE in
let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in
j0_BE
) else (
let padded_iv_quads = le_bytes_to_seq_quad32 (pad_to_128_bits iv) in
let length_BE = insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0 in
let length_LE = reverse_bytes_quad32 length_BE in
let hash_input_LE = append padded_iv_quads (create 1 length_LE) in
let hash_output_LE = ghash_LE h_LE hash_input_LE in
reverse_bytes_quad32 hash_output_LE
)
[@"opaque_to_smt"] let compute_iv_BE = opaque_make compute_iv_BE_def
irreducible let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GCM_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
plain: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8
-> Prims.Pure
(FStar.Seq.Base.seq Vale.Def.Types_s.nat8 * FStar.Seq.Base.seq Vale.Def.Types_s.nat8) | Prims.Pure | [] | [] | [
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Pervasives.Native.Mktuple2",
"Vale.Def.Words_s.nat8",
"Vale.AES.GCTR_s.gctr_encrypt_LE",
"Vale.Def.Types_s.le_quad32_to_bytes",
"Vale.Def.Types_s.quad32",
"Vale.AES.GHash_s.ghash_LE",
"FStar.Seq.Base.append",
"FStar.Seq.Base.create",
"Vale.Def.Types_s.le_bytes_to_seq_quad32",
"Vale.AES.GCTR_s.pad_to_128_bits",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.Def.Types_s.insert_nat64_def",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"FStar.Mul.op_Star",
"FStar.Seq.Base.length",
"Vale.AES.GCTR_s.inc32",
"Vale.AES.GCM_s.compute_iv_BE",
"Vale.AES.AES_s.aes_encrypt_LE",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE",
"FStar.Pervasives.Native.tuple2",
"Prims.l_and",
"Vale.AES.AES_common_s.is_aes_key",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.Def.Words_s.pow2_32",
"Prims.l_True"
] | [] | false | false | false | false | false | let gcm_encrypt_LE_def (alg: algorithm) (key: seq nat8) (iv: supported_iv_LE) (plain auth: seq nat8)
: Pure (seq nat8 & seq nat8)
(requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32)
(ensures fun (c, t) -> True) =
| let key_LE = seq_nat8_to_seq_nat32_LE key in
let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_LE iv in
let c = gctr_encrypt_LE (inc32 j0_BE 1) plain alg key_LE in
let lengths_BE =
insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0
in
let lengths_LE = reverse_bytes_quad32 lengths_BE in
let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits c) in
let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in
let s_LE = ghash_LE h_LE hash_input_LE in
let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in
(c, t) | false |
Vale.AES.GCM_s.fst | Vale.AES.GCM_s.gcm_decrypt_LE_def | val gcm_decrypt_LE_def
(alg: algorithm)
(key: seq nat8)
(iv: supported_iv_LE)
(cipher auth tag: seq nat8)
: Pure (seq nat8 & bool)
(requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32)
(ensures fun (p, t) -> True) | val gcm_decrypt_LE_def
(alg: algorithm)
(key: seq nat8)
(iv: supported_iv_LE)
(cipher auth tag: seq nat8)
: Pure (seq nat8 & bool)
(requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32)
(ensures fun (p, t) -> True) | let gcm_decrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (cipher:seq nat8) (auth:seq nat8) (tag:seq nat8) :
Pure (seq nat8 & bool)
(requires
is_aes_key alg key /\
length cipher < pow2_32 /\
length auth < pow2_32
)
(ensures fun (p, t) -> True)
=
let key_LE = seq_nat8_to_seq_nat32_LE key in
let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_LE iv in
let p = gctr_encrypt_LE (inc32 j0_BE 1) cipher alg key_LE in // TODO: Rename gctr_encrypt_LE to gctr_LE
let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length cipher) 0 in
let lengths_LE = reverse_bytes_quad32 lengths_BE in
let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in
let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in
let s_LE = ghash_LE h_LE hash_input_LE in
let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in
(p, t = tag) | {
"file_name": "vale/specs/crypto/Vale.AES.GCM_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 94,
"start_col": 0,
"start_line": 69
} | module Vale.AES.GCM_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GHash_s
open FStar.Seq
open FStar.Mul
unfold type gcm_plain_LE = gctr_plain_LE
unfold type gcm_auth_LE = gctr_plain_LE
#reset-options "--z3rlimit 30"
type supported_iv_LE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 }
let compute_iv_BE_def (h_LE:quad32) (iv:supported_iv_LE) : quad32
=
if 8 * (length iv) = 96 then (
let iv_LE = le_bytes_to_quad32 (pad_to_128_bits iv) in
let iv_BE = reverse_bytes_quad32 iv_LE in
let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in
j0_BE
) else (
let padded_iv_quads = le_bytes_to_seq_quad32 (pad_to_128_bits iv) in
let length_BE = insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0 in
let length_LE = reverse_bytes_quad32 length_BE in
let hash_input_LE = append padded_iv_quads (create 1 length_LE) in
let hash_output_LE = ghash_LE h_LE hash_input_LE in
reverse_bytes_quad32 hash_output_LE
)
[@"opaque_to_smt"] let compute_iv_BE = opaque_make compute_iv_BE_def
irreducible let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def
// little-endian
let gcm_encrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (plain:seq nat8) (auth:seq nat8) :
Pure (seq nat8 & seq nat8)
(requires
is_aes_key alg key /\
length plain < pow2_32 /\
length auth < pow2_32
)
(ensures fun (c, t) -> True)
=
let key_LE = seq_nat8_to_seq_nat32_LE key in
let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_LE iv in
let c = gctr_encrypt_LE (inc32 j0_BE 1) plain alg key_LE in
// Sets the first 64-bit number to 8 * length plain, and the second to 8* length auth
let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0 in
let lengths_LE = reverse_bytes_quad32 lengths_BE in
let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits c) in
let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in
let s_LE = ghash_LE h_LE hash_input_LE in
let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in
(c, t)
[@"opaque_to_smt"] let gcm_encrypt_LE = opaque_make gcm_encrypt_LE_def
irreducible let gcm_encrypt_LE_reveal = opaque_revealer (`%gcm_encrypt_LE) gcm_encrypt_LE gcm_encrypt_LE_def | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GCM_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
cipher: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
tag: FStar.Seq.Base.seq Vale.Def.Types_s.nat8
-> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat8 * Prims.bool) | Prims.Pure | [] | [] | [
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"Prims.op_Equality",
"Vale.Def.Words_s.nat8",
"Vale.AES.GCTR_s.gctr_encrypt_LE",
"Vale.Def.Types_s.le_quad32_to_bytes",
"Vale.Def.Types_s.quad32",
"Vale.AES.GHash_s.ghash_LE",
"FStar.Seq.Base.append",
"FStar.Seq.Base.create",
"Vale.Def.Types_s.le_bytes_to_seq_quad32",
"Vale.AES.GCTR_s.pad_to_128_bits",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.Def.Types_s.insert_nat64_def",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"FStar.Mul.op_Star",
"FStar.Seq.Base.length",
"Vale.AES.GCTR_s.inc32",
"Vale.AES.GCM_s.compute_iv_BE",
"Vale.AES.AES_s.aes_encrypt_LE",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE",
"FStar.Pervasives.Native.tuple2",
"Prims.l_and",
"Vale.AES.AES_common_s.is_aes_key",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.Def.Words_s.pow2_32",
"Prims.l_True"
] | [] | false | false | false | false | false | let gcm_decrypt_LE_def
(alg: algorithm)
(key: seq nat8)
(iv: supported_iv_LE)
(cipher auth tag: seq nat8)
: Pure (seq nat8 & bool)
(requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32)
(ensures fun (p, t) -> True) =
| let key_LE = seq_nat8_to_seq_nat32_LE key in
let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_LE iv in
let p = gctr_encrypt_LE (inc32 j0_BE 1) cipher alg key_LE in
let lengths_BE =
insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length cipher) 0
in
let lengths_LE = reverse_bytes_quad32 lengths_BE in
let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in
let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in
let s_LE = ghash_LE h_LE hash_input_LE in
let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in
(p, t = tag) | false |
Hacl.Spec.K256.Field52.Lemmas4.fst | Hacl.Spec.K256.Field52.Lemmas4.lemma_mul_ab | val lemma_mul_ab (a0 a1 a2 a3 a4 b0 b1 b2 b3 b4:nat) :
Lemma
(let sum0 = a0 * b0 in
let sum1 = a0 * b1 + a1 * b0 in
let sum2 = a0 * b2 + a1 * b1 + a2 * b0 in
let sum3 = a0 * b3 + a1 * b2 + a2 * b1 + a3 * b0 in
let sum4 = a0 * b4 + a1 * b3 + a2 * b2 + a3 * b1 + a4 * b0 in
let sum5 = a1 * b4 + a2 * b3 + a3 * b2 + a4 * b1 in
let sum6 = a2 * b4 + a3 * b3 + a4 * b2 in
let sum7 = a3 * b4 + a4 * b3 in
let sum8 = a4 * b4 in
(a0 + a1 * pow52 + a2 * pow104 + a3 * pow156 + a4 * pow208) *
(b0 + b1 * pow52 + b2 * pow104 + b3 * pow156 + b4 * pow208) =
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + sum3 * pow2 156 + sum4 * pow2 208 +
pow2 260 * (sum5 + sum6 * pow2 52 + sum7 * pow2 104 + sum8 * pow2 156)) | val lemma_mul_ab (a0 a1 a2 a3 a4 b0 b1 b2 b3 b4:nat) :
Lemma
(let sum0 = a0 * b0 in
let sum1 = a0 * b1 + a1 * b0 in
let sum2 = a0 * b2 + a1 * b1 + a2 * b0 in
let sum3 = a0 * b3 + a1 * b2 + a2 * b1 + a3 * b0 in
let sum4 = a0 * b4 + a1 * b3 + a2 * b2 + a3 * b1 + a4 * b0 in
let sum5 = a1 * b4 + a2 * b3 + a3 * b2 + a4 * b1 in
let sum6 = a2 * b4 + a3 * b3 + a4 * b2 in
let sum7 = a3 * b4 + a4 * b3 in
let sum8 = a4 * b4 in
(a0 + a1 * pow52 + a2 * pow104 + a3 * pow156 + a4 * pow208) *
(b0 + b1 * pow52 + b2 * pow104 + b3 * pow156 + b4 * pow208) =
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + sum3 * pow2 156 + sum4 * pow2 208 +
pow2 260 * (sum5 + sum6 * pow2 52 + sum7 * pow2 104 + sum8 * pow2 156)) | let lemma_mul_ab a0 a1 a2 a3 a4 b0 b1 b2 b3 b4 =
let sum0 = a0 * b0 in
let sum1 = a0 * b1 + a1 * b0 in
let sum2 = a0 * b2 + a1 * b1 + a2 * b0 in
let sum3 = a0 * b3 + a1 * b2 + a2 * b1 + a3 * b0 in
let sum4 = a0 * b4 + a1 * b3 + a2 * b2 + a3 * b1 + a4 * b0 in
let sum5 = a1 * b4 + a2 * b3 + a3 * b2 + a4 * b1 in
let sum6 = a2 * b4 + a3 * b3 + a4 * b2 in
let sum7 = a3 * b4 + a4 * b3 in
let sum8 = a4 * b4 in
let b_sum = b0 + b1 * pow52 + b2 * pow104 + b3 * pow156 + b4 * pow208 in
calc (==) {
(a0 + a1 * pow52 + a2 * pow104 + a3 * pow156 + a4 * pow208) * b_sum;
(==) { ML.lemma_distr5 a0 (a1 * pow52) (a2 * pow104) (a3 * pow156) (a4 * pow208) b_sum }
a0 * b_sum + a1 * pow52 * b_sum + a2 * pow104 * b_sum + a3 * pow156 * b_sum + a4 * pow208 * b_sum;
(==) { ML.lemma_distr5_pow52 a0 b0 b1 b2 b3 b4 }
sum0 + a0 * b1 * pow2 52 + a0 * b2 * pow2 104 + a0 * b3 * pow2 156 + a0 * b4 * pow2 208
+ a1 * pow52 * b_sum + a2 * pow104 * b_sum + a3 * pow156 * b_sum + a4 * pow208 * b_sum;
(==) { ML.lemma_distr5_pow52_mul_pow a1 b0 b1 b2 b3 b4 52 }
sum0 + a0 * b1 * pow2 52 + a0 * b2 * pow2 104 + a0 * b3 * pow2 156 + a0 * b4 * pow2 208
+ a1 * b0 * pow2 52 + a1 * b1 * pow2 104 + a1 * b2 * pow2 156 + a1 * b3 * pow2 208 + a1 * b4 * pow2 260
+ a2 * pow104 * b_sum + a3 * pow156 * b_sum + a4 * pow208 * b_sum;
(==) { ML.lemma_distr5_pow52_mul_pow a2 b0 b1 b2 b3 b4 104 }
sum0 + a0 * b1 * pow2 52 + a0 * b2 * pow2 104 + a0 * b3 * pow2 156 + a0 * b4 * pow2 208
+ a1 * b0 * pow2 52 + a1 * b1 * pow2 104 + a1 * b2 * pow2 156 + a1 * b3 * pow2 208 + a1 * b4 * pow2 260
+ a2 * b0 * pow2 104 + a2 * b1 * pow2 156 + a2 * b2 * pow2 208 + a2 * b3 * pow2 260 + a2 * b4 * pow2 312
+ a3 * pow156 * b_sum + a4 * pow208 * b_sum;
(==) { ML.lemma_distr5_pow52_mul_pow a3 b0 b1 b2 b3 b4 156 }
sum0 + a0 * b1 * pow2 52 + a0 * b2 * pow2 104 + a0 * b3 * pow2 156 + a0 * b4 * pow2 208
+ a1 * b0 * pow2 52 + a1 * b1 * pow2 104 + a1 * b2 * pow2 156 + a1 * b3 * pow2 208 + a1 * b4 * pow2 260
+ a2 * b0 * pow2 104 + a2 * b1 * pow2 156 + a2 * b2 * pow2 208 + a2 * b3 * pow2 260 + a2 * b4 * pow2 312
+ a3 * b0 * pow2 156 + a3 * b1 * pow2 208 + a3 * b2 * pow2 260 + a3 * b3 * pow2 312 + a3 * b4 * pow2 364
+ a4 * pow208 * b_sum;
(==) { ML.lemma_distr5_pow52_mul_pow a4 b0 b1 b2 b3 b4 208 }
sum0 + a0 * b1 * pow2 52 + a0 * b2 * pow2 104 + a0 * b3 * pow2 156 + a0 * b4 * pow2 208
+ a1 * b0 * pow2 52 + a1 * b1 * pow2 104 + a1 * b2 * pow2 156 + a1 * b3 * pow2 208 + a1 * b4 * pow2 260
+ a2 * b0 * pow2 104 + a2 * b1 * pow2 156 + a2 * b2 * pow2 208 + a2 * b3 * pow2 260 + a2 * b4 * pow2 312
+ a3 * b0 * pow2 156 + a3 * b1 * pow2 208 + a3 * b2 * pow2 260 + a3 * b3 * pow2 312 + a3 * b4 * pow2 364
+ a4 * b0 * pow2 208 + a4 * b1 * pow2 260 + a4 * b2 * pow2 312 + a4 * b3 * pow2 364 + a4 * b4 * pow2 416;
(==) { Math.Lemmas.distributivity_add_left (a0 * b1) (a1 * b0) (pow2 52) }
sum0 + sum1 * pow2 52 + a0 * b2 * pow2 104 + a0 * b3 * pow2 156 + a0 * b4 * pow2 208
+ a1 * b1 * pow2 104 + a1 * b2 * pow2 156 + a1 * b3 * pow2 208 + a1 * b4 * pow2 260
+ a2 * b0 * pow2 104 + a2 * b1 * pow2 156 + a2 * b2 * pow2 208 + a2 * b3 * pow2 260 + a2 * b4 * pow2 312
+ a3 * b0 * pow2 156 + a3 * b1 * pow2 208 + a3 * b2 * pow2 260 + a3 * b3 * pow2 312 + a3 * b4 * pow2 364
+ a4 * b0 * pow2 208 + a4 * b1 * pow2 260 + a4 * b2 * pow2 312 + a4 * b3 * pow2 364 + a4 * b4 * pow2 416;
(==) { ML.lemma_distr5 (a0 * b2) (a1 * b1) (a2 * b0) 0 0 (pow2 104) }
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + a0 * b3 * pow2 156 + a0 * b4 * pow2 208
+ a1 * b2 * pow2 156 + a1 * b3 * pow2 208 + a1 * b4 * pow2 260
+ a2 * b1 * pow2 156 + a2 * b2 * pow2 208 + a2 * b3 * pow2 260 + a2 * b4 * pow2 312
+ a3 * b0 * pow2 156 + a3 * b1 * pow2 208 + a3 * b2 * pow2 260 + a3 * b3 * pow2 312 + a3 * b4 * pow2 364
+ a4 * b0 * pow2 208 + a4 * b1 * pow2 260 + a4 * b2 * pow2 312 + a4 * b3 * pow2 364 + a4 * b4 * pow2 416;
(==) { ML.lemma_distr5 (a0 * b3) (a1 * b2) (a2 * b1) (a3 * b0) 0 (pow2 156) }
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + sum3 * pow2 156 + a0 * b4 * pow2 208
+ a1 * b3 * pow2 208 + a1 * b4 * pow2 260
+ a2 * b2 * pow2 208 + a2 * b3 * pow2 260 + a2 * b4 * pow2 312
+ a3 * b1 * pow2 208 + a3 * b2 * pow2 260 + a3 * b3 * pow2 312 + a3 * b4 * pow2 364
+ a4 * b0 * pow2 208 + a4 * b1 * pow2 260 + a4 * b2 * pow2 312 + a4 * b3 * pow2 364 + a4 * b4 * pow2 416;
(==) { ML.lemma_distr5 (a0 * b4) (a1 * b3) (a2 * b2) (a3 * b1) (a4 * b0) (pow2 208) }
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + sum3 * pow2 156 + sum4 * pow2 208
+ a1 * b4 * pow2 260
+ a2 * b3 * pow2 260 + a2 * b4 * pow2 312
+ a3 * b2 * pow2 260 + a3 * b3 * pow2 312 + a3 * b4 * pow2 364
+ a4 * b1 * pow2 260 + a4 * b2 * pow2 312 + a4 * b3 * pow2 364 + a4 * b4 * pow2 416;
(==) { ML.lemma_distr5 (a1 * b4) (a2 * b3) (a3 * b2) (a4 * b1) 0 (pow2 260) }
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + sum3 * pow2 156 + sum4 * pow2 208
+ sum5 * pow2 260
+ a2 * b4 * pow2 312
+ a3 * b3 * pow2 312 + a3 * b4 * pow2 364
+ a4 * b2 * pow2 312 + a4 * b3 * pow2 364 + a4 * b4 * pow2 416;
(==) { ML.lemma_distr5 (a2 * b4) (a3 * b3) (a4 * b2) 0 0 (pow2 312) }
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + sum3 * pow2 156 + sum4 * pow2 208
+ sum5 * pow2 260 + sum6 * pow2 312 + a3 * b4 * pow2 364 + a4 * b3 * pow2 364 + a4 * b4 * pow2 416;
(==) { Math.Lemmas.distributivity_add_left (a3 * b4) (a4 * b3) (pow2 364) }
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + sum3 * pow2 156 + sum4 * pow2 208
+ sum5 * pow2 260 + sum6 * pow2 312 + sum7 * pow2 364 + sum8 * pow2 416;
(==) { ML.lemma_distr5_pow52_mul_pow 1 sum5 sum6 sum7 sum8 0 260 }
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + sum3 * pow2 156 + sum4 * pow2 208
+ pow2 260 * (sum5 + sum6 * pow2 52 + sum7 * pow2 104 + sum8 * pow2 156);
} | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.Lemmas4.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 294,
"start_col": 0,
"start_line": 215
} | module Hacl.Spec.K256.Field52.Lemmas4
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
include Hacl.Spec.K256.Field52
module ML = Hacl.Spec.K256.MathLemmas
module LD = Hacl.Spec.K256.Field52.Definitions.Lemmas
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
val lemma_nat_r432 (r2 r3 r4 c9 c11 d4 d11 t3 r:nat) : Lemma
(requires
r2 = c9 % pow2 52 /\ c11 = c9 / pow2 52 + r * pow2 12 * d11 + t3 /\
r3 = c11 % pow2 52 /\ r4 = c11 / pow2 52 + (d4 % pow2 52) % pow2 48)
(ensures
(r4 * pow2 52 + r3) * pow2 52 + r2 =
c9 + r * d11 * pow2 64 + t3 * pow2 52 + (d4 % pow2 48) * pow2 104)
let lemma_nat_r432 r2 r3 r4 c9 c11 d4 d11 t3 r =
let k = d4 % pow2 48 in
calc (==) {
(r4 * pow2 52 + r3) * pow2 52 + r2;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 d4 48 52 }
((c11 / pow2 52 + k) * pow2 52 + c11 % pow2 52) * pow2 52 + r2;
(==) { ML.lemma_distr_eucl c11 k }
(c9 / pow2 52 + r * pow2 12 * d11 + t3 + k * pow2 52) * pow2 52 + c9 % pow2 52;
(==) { ML.lemma_distr_eucl c9 (r * pow2 12 * d11 + t3 + k * pow2 52) }
c9 + (r * pow2 12 * d11 + t3 + k * pow2 52) * pow2 52;
(==) { ML.lemma_distr_pow (r * pow2 12 * d11 + t3) k 52 52 }
c9 + (r * pow2 12 * d11 + t3) * pow2 52 + k * pow2 104;
(==) { ML.lemma_swap_mul3 r (pow2 12) d11 }
c9 + (r * d11 * pow2 12 + t3) * pow2 52 + k * pow2 104;
(==) { ML.lemma_distr_pow t3 (r * d11) 12 52 }
c9 + r * d11 * pow2 64 + t3 * pow2 52 + k * pow2 104;
}
val lemma_nat_r4321 (r1 r2 r3 r4 c6 c9 c11 d4 d10 d11 t3 r sum2:nat) : Lemma
(requires
d11 = d10 / pow2 64 /\
r1 = c6 % pow2 52 /\ c9 = c6 / pow2 52 + sum2 + r * (d10 % pow2 64) /\
r2 = c9 % pow2 52 /\ c11 = c9 / pow2 52 + r * pow2 12 * d11 + t3 /\
r3 = c11 % pow2 52 /\ r4 = c11 / pow2 52 + (d4 % pow2 52) % pow2 48)
(ensures
((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 52 + r1 =
c6 + sum2 * pow2 52 + r * d10 * pow2 52 + t3 * pow2 104 + (d4 % pow2 48) * pow2 156)
let lemma_nat_r4321 r1 r2 r3 r4 c6 c9 c11 d4 d10 d11 t3 r sum2 =
let k = d4 % pow2 48 in
let tmp1 = t3 * pow2 52 + k * pow2 104 in
calc (==) {
((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 52 + r1;
(==) { lemma_nat_r432 r2 r3 r4 c9 c11 d4 d11 t3 r }
(c9 + r * d11 * pow2 64 + tmp1) * pow2 52 + r1;
(==) { }
(c6 / pow2 52 + sum2 + r * (d10 % pow2 64) + r * d11 * pow2 64 + tmp1) * pow2 52 + c6 % pow2 52;
(==) { ML.lemma_distr_eucl_mul r d10 (pow2 64) }
(c6 / pow2 52 + sum2 + r * d10 + tmp1) * pow2 52 + c6 % pow2 52;
(==) { ML.lemma_distr_eucl c6 (sum2 + r * d10 + tmp1) }
c6 + (sum2 + r * d10 + tmp1) * pow2 52;
(==) { Math.Lemmas.distributivity_add_left (sum2 + r * d10) tmp1 (pow2 52) }
c6 + (sum2 + r * d10) * pow2 52 + tmp1 * pow2 52;
(==) { Math.Lemmas.distributivity_add_left sum2 (r * d10) (pow2 52) }
c6 + sum2 * pow2 52 + r * d10 * pow2 52 + tmp1 * pow2 52;
(==) { ML.lemma_distr_pow_pow t3 52 k 104 52 }
c6 + sum2 * pow2 52 + r * d10 * pow2 52 + t3 * pow2 104 + k * pow2 156;
}
val lemma_nat_r43210 (r0 r1 r2 r3 r4 c3 c6 c9 c11 d4 d8 d10 d11 t3 r sum1 sum2 sum7:nat) : Lemma
(requires
d10 == d8 / pow2 52 + sum7 /\
r0 = c3 % pow2 52 /\ c6 = c3 / pow2 52 + sum1 + d8 % pow2 52 * r /\
d11 = d10 / pow2 64 /\
r1 = c6 % pow2 52 /\ c9 = c6 / pow2 52 + sum2 + r * (d10 % pow2 64) /\
r2 = c9 % pow2 52 /\ c11 = c9 / pow2 52 + r * pow2 12 * d11 + t3 /\
r3 = c11 % pow2 52 /\ r4 = c11 / pow2 52 + (d4 % pow2 52) % pow2 48)
(ensures
r0 + r1 * pow52 + r2 * pow104 + r3 * pow156 + r4 * pow208 =
c3 + (sum1 + r * d8) * pow2 52 + (sum2 + r * sum7) * pow2 104 + t3 * pow2 156 + (d4 % pow2 48) * pow2 208)
let lemma_nat_r43210 r0 r1 r2 r3 r4 c3 c6 c9 c11 d4 d8 d10 d11 t3 r sum1 sum2 sum7 =
let k = d4 % pow2 48 in
let tmp1 = sum2 * pow2 52 + t3 * pow2 104 + k * pow2 156 in
calc (==) { // tmp1 * pow2 52
(sum2 * pow2 52 + t3 * pow2 104 + k * pow2 156) * pow2 52;
(==) { ML.lemma_distr_pow (sum2 * pow2 52 + t3 * pow2 104) k 156 52 }
(sum2 * pow2 52 + t3 * pow2 104) * pow2 52 + k * pow2 208;
(==) { ML.lemma_distr_pow_pow sum2 52 t3 104 52 }
sum2 * pow2 104 + t3 * pow2 156 + k * pow2 208;
};
calc (==) {
r0 + r1 * pow52 + r2 * pow104 + r3 * pow156 + r4 * pow208;
(==) { ML.lemma_as_nat_horner r0 r1 r2 r3 r4 }
(((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 52 + r1) * pow2 52 + r0;
(==) { lemma_nat_r4321 r1 r2 r3 r4 c6 c9 c11 d4 d10 d11 t3 r sum2 }
(c3 / pow2 52 + sum1 + d8 % pow2 52 * r + r * (d8 / pow2 52 + sum7) * pow2 52 + tmp1) * pow2 52 + c3 % pow2 52;
(==) { ML.lemma_distr_eucl_mul_add r d8 sum7 (pow2 52) }
(c3 / pow2 52 + sum1 + r * d8 + r * sum7 * pow2 52 + tmp1) * pow2 52 + c3 % pow2 52;
(==) { ML.lemma_distr_eucl c3 (sum1 + r * d8 + r * sum7 * pow2 52 + tmp1) }
c3 + (sum1 + r * d8 + r * sum7 * pow2 52 + tmp1) * pow2 52;
(==) { ML.lemma_distr_pow (sum1 + r * d8 + tmp1) (r * sum7) 52 52 }
c3 + (sum1 + r * d8 + tmp1) * pow2 52 + r * sum7 * pow2 104;
(==) { Math.Lemmas.distributivity_add_left (sum1 + r * d8) tmp1 (pow2 52) }
c3 + (sum1 + r * d8) * pow2 52 + sum2 * pow2 104 + t3 * pow2 156 + k * pow2 208 + r * sum7 * pow2 104;
(==) { Math.Lemmas.distributivity_add_left sum2 (r * sum7) (pow2 104) }
c3 + (sum1 + r * d8) * pow2 52 + (sum2 + r * sum7) * pow2 104 + t3 * pow2 156 + k * pow2 208;
}
val simplify_c3 (d4 r sum5:nat) : Lemma
(requires r % pow2 4 = 0)
(ensures (let k = (d4 / pow2 52 + sum5) % pow2 52 in
((d4 % pow2 52) / pow2 48 + k * pow2 4) * (r / pow2 4) ==
(d4 / pow2 48) * (r / pow2 4) + (k - (d4 / pow2 52)) * r))
let simplify_c3 d4 r sum5 =
let k = (d4 / pow2 52 + sum5) % pow2 52 in
calc (==) { //simplify c3
((d4 % pow2 52) / pow2 48 + k * pow2 4) * (r / pow2 4);
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 d4 48 52 }
((d4 / pow2 48) % pow2 4 + k * pow2 4) * (r / pow2 4);
(==) { Math.Lemmas.euclidean_division_definition (d4 / pow2 48) (pow2 4) }
(d4 / pow2 48 - (d4 / pow2 48 / pow2 4) * pow2 4 + k * pow2 4) * (r / pow2 4);
(==) { Math.Lemmas.division_multiplication_lemma d4 (pow2 48) (pow2 4); Math.Lemmas.pow2_plus 48 4 }
(d4 / pow2 48 - (d4 / pow2 52) * pow2 4 + k * pow2 4) * (r / pow2 4);
(==) { Math.Lemmas.distributivity_sub_left k (d4 / pow2 52) (pow2 4) }
(d4 / pow2 48 + (k - d4 / pow2 52) * pow2 4) * (r / pow2 4);
(==) { Math.Lemmas.distributivity_add_left (d4 / pow2 48) ((k - d4 / pow2 52) * pow2 4) (r / pow2 4) }
(d4 / pow2 48) * (r / pow2 4) + (k - d4 / pow2 52) * pow2 4 * (r / pow2 4);
(==) { Math.Lemmas.paren_mul_right (k - d4 / pow2 52) (pow2 4) (r / pow2 4); Math.Lemmas.div_exact_r r (pow2 4) }
(d4 / pow2 48) * (r / pow2 4) + (k - d4 / pow2 52) * r;
}
val lemma_nat_r43210_mod_prime (c3 d4 d8 t3 r sum0 sum1 sum2 sum3 sum4 sum5 sum6 sum7 sum8: nat) : Lemma
(requires
r = 0x1000003D10 /\
d4 = (sum3 + r * (sum8 % pow2 64)) / pow2 52 + sum4 + r * pow2 12 * (sum8 / pow2 64) /\
t3 = (sum3 + r * (sum8 % pow2 64)) % pow2 52 /\
d8 = (d4 / pow2 52 + sum5) / pow2 52 + sum6 /\
c3 = sum0 + ((d4 % pow2 52) / pow2 48 + ((d4 / pow2 52 + sum5) % pow2 52) * pow2 4) * (r / pow2 4))
(ensures
(c3 + (sum1 + r * d8) * pow2 52 + (sum2 + r * sum7) * pow2 104 +
t3 * pow2 156 + (d4 % pow2 48) * pow2 208) % S.prime ==
(sum0 + sum5 * r + (sum1 + sum6 * r) * pow2 52 + (sum2 + r * sum7) * pow2 104 +
(sum3 + r * sum8) * pow2 156 + sum4 * pow2 208) % S.prime)
let lemma_nat_r43210_mod_prime c3 d4 d8 t3 r sum0 sum1 sum2 sum3 sum4 sum5 sum6 sum7 sum8 =
let tmp2 = sum3 + r * (sum8 % pow2 64) in
let tmp1 = d4 / pow2 52 + sum5 in
let tmp0 = sum0 + (tmp1 % pow2 52 - d4 / pow2 52) * r in
let d4mod = (d4 % pow2 48) * pow2 208 + (d4 / pow2 48) * 0x1000003D1 in
calc (==) {
c3 + (d4 % pow2 48) * pow2 208 + (sum1 + r * d8) * pow2 52;
(==) { simplify_c3 d4 r sum5; assert_norm (0x1000003D10 / pow2 4 = 0x1000003D1) }
d4mod + tmp0 + (sum1 + r * d8) * pow2 52;
(==) { Math.Lemmas.distributivity_add_left sum1 (r * d8) (pow2 52) }
d4mod + sum0 + (tmp1 % pow2 52 - d4 / pow2 52) * r + sum1 * pow2 52 + r * (tmp1 / pow2 52 + sum6) * pow2 52;
(==) { Math.Lemmas.distributivity_sub_left (tmp1 % pow2 52) (d4 / pow2 52) r }
d4mod + sum0 + (tmp1 % pow2 52) * r - d4 / pow2 52 * r + sum1 * pow2 52 + r * (tmp1 / pow2 52 + sum6) * pow2 52;
(==) { ML.lemma_distr_eucl_mul_add r tmp1 sum6 (pow2 52) }
d4mod + sum0 + r * (d4 / pow2 52 + sum5) - d4 / pow2 52 * r + sum1 * pow2 52 + r * sum6 * pow2 52;
(==) { Math.Lemmas.distributivity_add_right r (d4 / pow2 52) sum5 }
d4mod + sum0 + r * sum5 + sum1 * pow2 52 + r * sum6 * pow2 52;
(==) { Math.Lemmas.distributivity_add_left sum1 (r * sum6) (pow2 52) }
d4mod + sum0 + r * sum5 + (sum1 + r * sum6) * pow2 52;
};
calc (==) { //t3 * pow2 156 + d4 * pow2 208;
(tmp2 % pow2 52) * pow2 156 + (tmp2 / pow2 52 + sum4 + r * pow2 12 * (sum8 / pow2 64)) * pow2 208;
(==) { ML.lemma_distr_pow (tmp2 % pow2 52) (tmp2 / pow2 52 + sum4 + r * pow2 12 * (sum8 / pow2 64)) 52 156 }
(tmp2 % pow2 52 + (tmp2 / pow2 52 + sum4 + r * pow2 12 * (sum8 / pow2 64)) * pow2 52) * pow2 156;
(==) { ML.lemma_distr_eucl_mul_add 1 tmp2 (sum4 + r * pow2 12 * (sum8 / pow2 64)) (pow2 52) }
(tmp2 + (sum4 + r * pow2 12 * (sum8 / pow2 64)) * pow2 52) * pow2 156;
(==) { ML.lemma_swap_mul3 r (pow2 12) (sum8 / pow2 64) }
(tmp2 + (sum4 + r * (sum8 / pow2 64) * pow2 12) * pow2 52) * pow2 156;
(==) { ML.lemma_distr_pow sum4 (r * (sum8 / pow2 64)) 12 52 }
(sum3 + r * (sum8 % pow2 64) + sum4 * pow2 52 + r * (sum8 / pow2 64) * pow2 64) * pow2 156;
(==) { ML.lemma_distr_eucl_mul r sum8 (pow2 64) }
(sum3 + r * sum8 + sum4 * pow2 52) * pow2 156;
(==) { ML.lemma_distr_pow (sum3 + r * sum8) sum4 52 156 }
(sum3 + r * sum8) * pow2 156 + sum4 * pow2 208;
};
LD.as_nat_mod_prime (sum0 + r * sum5) (sum1 + r * sum6) (sum2 + r * sum7) t3 d4
val lemma_mul_ab (a0 a1 a2 a3 a4 b0 b1 b2 b3 b4:nat) :
Lemma
(let sum0 = a0 * b0 in
let sum1 = a0 * b1 + a1 * b0 in
let sum2 = a0 * b2 + a1 * b1 + a2 * b0 in
let sum3 = a0 * b3 + a1 * b2 + a2 * b1 + a3 * b0 in
let sum4 = a0 * b4 + a1 * b3 + a2 * b2 + a3 * b1 + a4 * b0 in
let sum5 = a1 * b4 + a2 * b3 + a3 * b2 + a4 * b1 in
let sum6 = a2 * b4 + a3 * b3 + a4 * b2 in
let sum7 = a3 * b4 + a4 * b3 in
let sum8 = a4 * b4 in
(a0 + a1 * pow52 + a2 * pow104 + a3 * pow156 + a4 * pow208) *
(b0 + b1 * pow52 + b2 * pow104 + b3 * pow156 + b4 * pow208) =
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + sum3 * pow2 156 + sum4 * pow2 208 +
pow2 260 * (sum5 + sum6 * pow2 52 + sum7 * pow2 104 + sum8 * pow2 156)) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.MathLemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.Lemmas4.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Definitions.Lemmas",
"short_module": "LD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.MathLemmas",
"short_module": "ML"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a0: Prims.nat ->
a1: Prims.nat ->
a2: Prims.nat ->
a3: Prims.nat ->
a4: Prims.nat ->
b0: Prims.nat ->
b1: Prims.nat ->
b2: Prims.nat ->
b3: Prims.nat ->
b4: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
(let sum0 = a0 * b0 in
let sum1 = a0 * b1 + a1 * b0 in
let sum2 = a0 * b2 + a1 * b1 + a2 * b0 in
let sum3 = a0 * b3 + a1 * b2 + a2 * b1 + a3 * b0 in
let sum4 = a0 * b4 + a1 * b3 + a2 * b2 + a3 * b1 + a4 * b0 in
let sum5 = a1 * b4 + a2 * b3 + a3 * b2 + a4 * b1 in
let sum6 = a2 * b4 + a3 * b3 + a4 * b2 in
let sum7 = a3 * b4 + a4 * b3 in
let sum8 = a4 * b4 in
(a0 + a1 * Hacl.Spec.K256.Field52.Definitions.pow52 +
a2 * Hacl.Spec.K256.Field52.Definitions.pow104 +
a3 * Hacl.Spec.K256.Field52.Definitions.pow156 +
a4 * Hacl.Spec.K256.Field52.Definitions.pow208) *
(b0 + b1 * Hacl.Spec.K256.Field52.Definitions.pow52 +
b2 * Hacl.Spec.K256.Field52.Definitions.pow104 +
b3 * Hacl.Spec.K256.Field52.Definitions.pow156 +
b4 * Hacl.Spec.K256.Field52.Definitions.pow208) =
sum0 + sum1 * Prims.pow2 52 + sum2 * Prims.pow2 104 + sum3 * Prims.pow2 156 +
sum4 * Prims.pow2 208 +
Prims.pow2 260 *
(sum5 + sum6 * Prims.pow2 52 + sum7 * Prims.pow2 104 + sum8 * Prims.pow2 156))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"FStar.Mul.op_Star",
"Prims.op_Addition",
"Hacl.Spec.K256.Field52.Definitions.pow52",
"Hacl.Spec.K256.Field52.Definitions.pow104",
"Hacl.Spec.K256.Field52.Definitions.pow156",
"Hacl.Spec.K256.Field52.Definitions.pow208",
"Prims.pow2",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Hacl.Spec.K256.MathLemmas.lemma_distr5",
"Prims.squash",
"Hacl.Spec.K256.MathLemmas.lemma_distr5_pow52",
"Hacl.Spec.K256.MathLemmas.lemma_distr5_pow52_mul_pow",
"FStar.Math.Lemmas.distributivity_add_left"
] | [] | false | false | true | false | false | let lemma_mul_ab a0 a1 a2 a3 a4 b0 b1 b2 b3 b4 =
| let sum0 = a0 * b0 in
let sum1 = a0 * b1 + a1 * b0 in
let sum2 = a0 * b2 + a1 * b1 + a2 * b0 in
let sum3 = a0 * b3 + a1 * b2 + a2 * b1 + a3 * b0 in
let sum4 = a0 * b4 + a1 * b3 + a2 * b2 + a3 * b1 + a4 * b0 in
let sum5 = a1 * b4 + a2 * b3 + a3 * b2 + a4 * b1 in
let sum6 = a2 * b4 + a3 * b3 + a4 * b2 in
let sum7 = a3 * b4 + a4 * b3 in
let sum8 = a4 * b4 in
let b_sum = b0 + b1 * pow52 + b2 * pow104 + b3 * pow156 + b4 * pow208 in
calc ( == ) {
(a0 + a1 * pow52 + a2 * pow104 + a3 * pow156 + a4 * pow208) * b_sum;
( == ) { ML.lemma_distr5 a0 (a1 * pow52) (a2 * pow104) (a3 * pow156) (a4 * pow208) b_sum }
a0 * b_sum + (a1 * pow52) * b_sum + (a2 * pow104) * b_sum + (a3 * pow156) * b_sum +
(a4 * pow208) * b_sum;
( == ) { ML.lemma_distr5_pow52 a0 b0 b1 b2 b3 b4 }
sum0 + (a0 * b1) * pow2 52 + (a0 * b2) * pow2 104 + (a0 * b3) * pow2 156 + (a0 * b4) * pow2 208 +
(a1 * pow52) * b_sum +
(a2 * pow104) * b_sum +
(a3 * pow156) * b_sum +
(a4 * pow208) * b_sum;
( == ) { ML.lemma_distr5_pow52_mul_pow a1 b0 b1 b2 b3 b4 52 }
sum0 + (a0 * b1) * pow2 52 + (a0 * b2) * pow2 104 + (a0 * b3) * pow2 156 + (a0 * b4) * pow2 208 +
(a1 * b0) * pow2 52 +
(a1 * b1) * pow2 104 +
(a1 * b2) * pow2 156 +
(a1 * b3) * pow2 208 +
(a1 * b4) * pow2 260 +
(a2 * pow104) * b_sum +
(a3 * pow156) * b_sum +
(a4 * pow208) * b_sum;
( == ) { ML.lemma_distr5_pow52_mul_pow a2 b0 b1 b2 b3 b4 104 }
sum0 + (a0 * b1) * pow2 52 + (a0 * b2) * pow2 104 + (a0 * b3) * pow2 156 + (a0 * b4) * pow2 208 +
(a1 * b0) * pow2 52 +
(a1 * b1) * pow2 104 +
(a1 * b2) * pow2 156 +
(a1 * b3) * pow2 208 +
(a1 * b4) * pow2 260 +
(a2 * b0) * pow2 104 +
(a2 * b1) * pow2 156 +
(a2 * b2) * pow2 208 +
(a2 * b3) * pow2 260 +
(a2 * b4) * pow2 312 +
(a3 * pow156) * b_sum +
(a4 * pow208) * b_sum;
( == ) { ML.lemma_distr5_pow52_mul_pow a3 b0 b1 b2 b3 b4 156 }
sum0 + (a0 * b1) * pow2 52 + (a0 * b2) * pow2 104 + (a0 * b3) * pow2 156 + (a0 * b4) * pow2 208 +
(a1 * b0) * pow2 52 +
(a1 * b1) * pow2 104 +
(a1 * b2) * pow2 156 +
(a1 * b3) * pow2 208 +
(a1 * b4) * pow2 260 +
(a2 * b0) * pow2 104 +
(a2 * b1) * pow2 156 +
(a2 * b2) * pow2 208 +
(a2 * b3) * pow2 260 +
(a2 * b4) * pow2 312 +
(a3 * b0) * pow2 156 +
(a3 * b1) * pow2 208 +
(a3 * b2) * pow2 260 +
(a3 * b3) * pow2 312 +
(a3 * b4) * pow2 364 +
(a4 * pow208) * b_sum;
( == ) { ML.lemma_distr5_pow52_mul_pow a4 b0 b1 b2 b3 b4 208 }
sum0 + (a0 * b1) * pow2 52 + (a0 * b2) * pow2 104 + (a0 * b3) * pow2 156 + (a0 * b4) * pow2 208 +
(a1 * b0) * pow2 52 +
(a1 * b1) * pow2 104 +
(a1 * b2) * pow2 156 +
(a1 * b3) * pow2 208 +
(a1 * b4) * pow2 260 +
(a2 * b0) * pow2 104 +
(a2 * b1) * pow2 156 +
(a2 * b2) * pow2 208 +
(a2 * b3) * pow2 260 +
(a2 * b4) * pow2 312 +
(a3 * b0) * pow2 156 +
(a3 * b1) * pow2 208 +
(a3 * b2) * pow2 260 +
(a3 * b3) * pow2 312 +
(a3 * b4) * pow2 364 +
(a4 * b0) * pow2 208 +
(a4 * b1) * pow2 260 +
(a4 * b2) * pow2 312 +
(a4 * b3) * pow2 364 +
(a4 * b4) * pow2 416;
( == ) { Math.Lemmas.distributivity_add_left (a0 * b1) (a1 * b0) (pow2 52) }
sum0 + sum1 * pow2 52 + (a0 * b2) * pow2 104 + (a0 * b3) * pow2 156 + (a0 * b4) * pow2 208 +
(a1 * b1) * pow2 104 +
(a1 * b2) * pow2 156 +
(a1 * b3) * pow2 208 +
(a1 * b4) * pow2 260 +
(a2 * b0) * pow2 104 +
(a2 * b1) * pow2 156 +
(a2 * b2) * pow2 208 +
(a2 * b3) * pow2 260 +
(a2 * b4) * pow2 312 +
(a3 * b0) * pow2 156 +
(a3 * b1) * pow2 208 +
(a3 * b2) * pow2 260 +
(a3 * b3) * pow2 312 +
(a3 * b4) * pow2 364 +
(a4 * b0) * pow2 208 +
(a4 * b1) * pow2 260 +
(a4 * b2) * pow2 312 +
(a4 * b3) * pow2 364 +
(a4 * b4) * pow2 416;
( == ) { ML.lemma_distr5 (a0 * b2) (a1 * b1) (a2 * b0) 0 0 (pow2 104) }
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + (a0 * b3) * pow2 156 + (a0 * b4) * pow2 208 +
(a1 * b2) * pow2 156 +
(a1 * b3) * pow2 208 +
(a1 * b4) * pow2 260 +
(a2 * b1) * pow2 156 +
(a2 * b2) * pow2 208 +
(a2 * b3) * pow2 260 +
(a2 * b4) * pow2 312 +
(a3 * b0) * pow2 156 +
(a3 * b1) * pow2 208 +
(a3 * b2) * pow2 260 +
(a3 * b3) * pow2 312 +
(a3 * b4) * pow2 364 +
(a4 * b0) * pow2 208 +
(a4 * b1) * pow2 260 +
(a4 * b2) * pow2 312 +
(a4 * b3) * pow2 364 +
(a4 * b4) * pow2 416;
( == ) { ML.lemma_distr5 (a0 * b3) (a1 * b2) (a2 * b1) (a3 * b0) 0 (pow2 156) }
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + sum3 * pow2 156 + (a0 * b4) * pow2 208 +
(a1 * b3) * pow2 208 +
(a1 * b4) * pow2 260 +
(a2 * b2) * pow2 208 +
(a2 * b3) * pow2 260 +
(a2 * b4) * pow2 312 +
(a3 * b1) * pow2 208 +
(a3 * b2) * pow2 260 +
(a3 * b3) * pow2 312 +
(a3 * b4) * pow2 364 +
(a4 * b0) * pow2 208 +
(a4 * b1) * pow2 260 +
(a4 * b2) * pow2 312 +
(a4 * b3) * pow2 364 +
(a4 * b4) * pow2 416;
( == ) { ML.lemma_distr5 (a0 * b4) (a1 * b3) (a2 * b2) (a3 * b1) (a4 * b0) (pow2 208) }
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + sum3 * pow2 156 + sum4 * pow2 208 + (a1 * b4) * pow2 260 +
(a2 * b3) * pow2 260 +
(a2 * b4) * pow2 312 +
(a3 * b2) * pow2 260 +
(a3 * b3) * pow2 312 +
(a3 * b4) * pow2 364 +
(a4 * b1) * pow2 260 +
(a4 * b2) * pow2 312 +
(a4 * b3) * pow2 364 +
(a4 * b4) * pow2 416;
( == ) { ML.lemma_distr5 (a1 * b4) (a2 * b3) (a3 * b2) (a4 * b1) 0 (pow2 260) }
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + sum3 * pow2 156 + sum4 * pow2 208 + sum5 * pow2 260 +
(a2 * b4) * pow2 312 +
(a3 * b3) * pow2 312 +
(a3 * b4) * pow2 364 +
(a4 * b2) * pow2 312 +
(a4 * b3) * pow2 364 +
(a4 * b4) * pow2 416;
( == ) { ML.lemma_distr5 (a2 * b4) (a3 * b3) (a4 * b2) 0 0 (pow2 312) }
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + sum3 * pow2 156 + sum4 * pow2 208 + sum5 * pow2 260 +
sum6 * pow2 312 +
(a3 * b4) * pow2 364 +
(a4 * b3) * pow2 364 +
(a4 * b4) * pow2 416;
( == ) { Math.Lemmas.distributivity_add_left (a3 * b4) (a4 * b3) (pow2 364) }
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + sum3 * pow2 156 + sum4 * pow2 208 + sum5 * pow2 260 +
sum6 * pow2 312 +
sum7 * pow2 364 +
sum8 * pow2 416;
( == ) { ML.lemma_distr5_pow52_mul_pow 1 sum5 sum6 sum7 sum8 0 260 }
sum0 + sum1 * pow2 52 + sum2 * pow2 104 + sum3 * pow2 156 + sum4 * pow2 208 +
pow2 260 * (sum5 + sum6 * pow2 52 + sum7 * pow2 104 + sum8 * pow2 156);
} | false |
Steel.ST.C.Types.Base.fsti | Steel.ST.C.Types.Base.assert_null | val assert_null (#t: Type) (#opened: _) (#td: typedef t) (#v: Ghost.erased t) (p: ptr td)
: STGhost unit opened (pts_to_or_null p v) (fun _ -> emp) (p == null _) (fun _ -> True) | val assert_null (#t: Type) (#opened: _) (#td: typedef t) (#v: Ghost.erased t) (p: ptr td)
: STGhost unit opened (pts_to_or_null p v) (fun _ -> emp) (p == null _) (fun _ -> True) | let assert_null
(#t: Type)
(#opened: _)
(#td: typedef t)
(#v: Ghost.erased t)
(p: ptr td)
: STGhost unit opened
(pts_to_or_null p v)
(fun _ -> emp)
(p == null _)
(fun _ -> True)
= rewrite (pts_to_or_null p v) emp | {
"file_name": "lib/steel/c/Steel.ST.C.Types.Base.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 34,
"end_line": 135,
"start_col": 0,
"start_line": 124
} | module Steel.ST.C.Types.Base
open Steel.ST.Util
module P = Steel.FractionalPermission
/// Helper to compose two permissions into one
val prod_perm (p1 p2: P.perm) : Pure P.perm
(requires True)
(ensures (fun p ->
((p1 `P.lesser_equal_perm` P.full_perm /\ p2 `P.lesser_equal_perm` P.full_perm) ==>
p `P.lesser_equal_perm` P.full_perm) /\
p.v == (let open FStar.Real in p1.v *. p2.v)
))
[@@noextract_to "krml"] // proof-only
val typedef (t: Type0) : Type0
inline_for_extraction [@@noextract_to "krml"]
let typeof (#t: Type0) (td: typedef t) : Tot Type0 = t
val fractionable (#t: Type0) (td: typedef t) (x: t) : GTot prop
val mk_fraction (#t: Type0) (td: typedef t) (x: t) (p: P.perm) : Ghost t
(requires (fractionable td x))
(ensures (fun y -> p `P.lesser_equal_perm` P.full_perm ==> fractionable td y))
val mk_fraction_full (#t: Type0) (td: typedef t) (x: t) : Lemma
(requires (fractionable td x))
(ensures (mk_fraction td x P.full_perm == x))
[SMTPat (mk_fraction td x P.full_perm)]
val mk_fraction_compose (#t: Type0) (td: typedef t) (x: t) (p1 p2: P.perm) : Lemma
(requires (fractionable td x /\ p1 `P.lesser_equal_perm` P.full_perm /\ p2 `P.lesser_equal_perm` P.full_perm))
(ensures (mk_fraction td (mk_fraction td x p1) p2 == mk_fraction td x (p1 `prod_perm` p2)))
val full (#t: Type0) (td: typedef t) (v: t) : GTot prop
val uninitialized (#t: Type0) (td: typedef t) : Ghost t
(requires True)
(ensures (fun y -> full td y /\ fractionable td y))
val unknown (#t: Type0) (td: typedef t) : Ghost t
(requires True)
(ensures (fun y -> fractionable td y))
val full_not_unknown
(#t: Type)
(td: typedef t)
(v: t)
: Lemma
(requires (full td v))
(ensures (~ (v == unknown td)))
[SMTPat (full td v)]
val mk_fraction_unknown (#t: Type0) (td: typedef t) (p: P.perm) : Lemma
(ensures (mk_fraction td (unknown td) p == unknown td))
val mk_fraction_eq_unknown (#t: Type0) (td: typedef t) (v: t) (p: P.perm) : Lemma
(requires (fractionable td v /\ mk_fraction td v p == unknown td))
(ensures (v == unknown td))
// To be extracted as: void*
[@@noextract_to "krml"] // primitive
val void_ptr : Type0
// To be extracted as: NULL
[@@noextract_to "krml"] // primitive
val void_null: void_ptr
// To be extracted as: *t
[@@noextract_to "krml"] // primitive
val ptr_gen ([@@@unused] t: Type) : Type0
[@@noextract_to "krml"] // primitive
val null_gen (t: Type) : Tot (ptr_gen t)
val ghost_void_ptr_of_ptr_gen (#[@@@unused] t: Type) (x: ptr_gen t) : GTot void_ptr
val ghost_ptr_gen_of_void_ptr (x: void_ptr) ([@@@unused] t: Type) : GTot (ptr_gen t)
val ghost_void_ptr_of_ptr_gen_of_void_ptr
(x: void_ptr)
(t: Type)
: Lemma
(ghost_void_ptr_of_ptr_gen (ghost_ptr_gen_of_void_ptr x t) == x)
[SMTPat (ghost_void_ptr_of_ptr_gen (ghost_ptr_gen_of_void_ptr x t))]
val ghost_ptr_gen_of_void_ptr_of_ptr_gen
(#t: Type)
(x: ptr_gen t)
: Lemma
(ghost_ptr_gen_of_void_ptr (ghost_void_ptr_of_ptr_gen x) t == x)
[SMTPat (ghost_ptr_gen_of_void_ptr (ghost_void_ptr_of_ptr_gen x) t)]
inline_for_extraction [@@noextract_to "krml"] // primitive
let ptr (#t: Type) (td: typedef t) : Tot Type0 = ptr_gen t
inline_for_extraction [@@noextract_to "krml"] // primitive
let null (#t: Type) (td: typedef t) : Tot (ptr td) = null_gen t
inline_for_extraction [@@noextract_to "krml"]
let ref (#t: Type) (td: typedef t) : Tot Type0 = (p: ptr td { ~ (p == null td) })
val pts_to (#t: Type) (#td: typedef t) (r: ref td) ([@@@smt_fallback] v: Ghost.erased t) : vprop
let pts_to_or_null
(#t: Type) (#td: typedef t) (p: ptr td) (v: Ghost.erased t) : vprop
= if FStar.StrongExcludedMiddle.strong_excluded_middle (p == null _)
then emp
else pts_to p v
[@@noextract_to "krml"] // primitive
val is_null
(#t: Type)
(#opened: _)
(#td: typedef t)
(#v: Ghost.erased t)
(p: ptr td)
: STAtomicBase bool false opened Unobservable
(pts_to_or_null p v)
(fun _ -> pts_to_or_null p v)
(True)
(fun res -> res == true <==> p == null _) | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.C.Types.Base.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.ptr td -> Steel.ST.Effect.Ghost.STGhost Prims.unit | Steel.ST.Effect.Ghost.STGhost | [] | [] | [
"Steel.Memory.inames",
"Steel.ST.C.Types.Base.typedef",
"FStar.Ghost.erased",
"Steel.ST.C.Types.Base.ptr",
"Steel.ST.Util.rewrite",
"Steel.ST.C.Types.Base.pts_to_or_null",
"Steel.Effect.Common.emp",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.eq2",
"Steel.ST.C.Types.Base.null",
"Prims.l_True"
] | [] | false | true | false | false | false | let assert_null (#t: Type) (#opened: _) (#td: typedef t) (#v: Ghost.erased t) (p: ptr td)
: STGhost unit opened (pts_to_or_null p v) (fun _ -> emp) (p == null _) (fun _ -> True) =
| rewrite (pts_to_or_null p v) emp | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_128 | val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code | val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code | let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ()))))))))) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 50,
"end_line": 42,
"start_col": 0,
"start_line": 35
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Vale.PPC64LE.InsVector.va_code_Vmr",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.AES.PPC64LE.GF128_Mul.va_code_ShiftLeft128_1",
"Vale.AES.PPC64LE.PolyOps.va_code_VPolyAnd",
"Vale.PPC64LE.InsVector.va_code_Vcmpequw",
"Vale.PPC64LE.InsVector.va_code_Vspltw",
"Vale.AES.PPC64LE.PolyOps.va_code_VPolyAdd",
"Vale.PPC64LE.Decls.va_CNil",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_ShiftKey1_128 () =
| (va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_CCons (va_code_ShiftLeft128_1 ())
(va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 5))
(va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 5))
(va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4))
(va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 3))
(va_CNil ()))))))))) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_codegen_success_ShiftKey1_gf128_power | val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool | val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool | let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ()))))))))))) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 31,
"end_line": 195,
"start_col": 0,
"start_line": 184
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_pbool_and",
"Vale.PPC64LE.InsVector.va_codegen_success_Vspltisw",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.PPC64LE.InsBasic.va_codegen_success_LoadImmShl64",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Prims.op_Minus",
"Vale.PPC64LE.InsVector.va_codegen_success_Mtvsrws",
"Vale.PPC64LE.InsVector.va_codegen_success_Vsldoi",
"Vale.AES.PPC64LE.GF128_Init.va_codegen_success_ShiftKey1_128",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_ShiftKey1_gf128_power () =
| (va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0)
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1)
(va_pbool_and (va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (- 15872))
(va_pbool_and (va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10))
(va_pbool_and (va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (- 32768))
(va_pbool_and (va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5)
(va_op_reg_opr_reg 10))
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 1)
8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1)
12)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 2)
4)
(va_pbool_and (va_codegen_success_ShiftKey1_128 ())
(va_ttrue ()))))))))))) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_wp_ShiftKey1_128 | val va_wp_ShiftKey1_128 (f: poly) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 | val va_wp_ShiftKey1_128 (f: poly) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 | let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (()))) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 85,
"end_line": 144,
"start_col": 0,
"start_line": 132
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
f: Vale.Math.Poly2_s.poly ->
va_s0: Vale.PPC64LE.Decls.va_state ->
va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.Math.Poly2_s.poly",
"Vale.PPC64LE.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Prims.eq2",
"Vale.Math.Poly2.Bits_s.of_quad32",
"Vale.PPC64LE.Decls.va_get_vec",
"Vale.Math.Poly2_s.monomial",
"Vale.Math.Poly2_s.reverse",
"Vale.Math.Poly2_s.shift",
"Vale.Math.Poly2_s.add",
"Prims.op_Minus",
"Prims.l_Forall",
"Vale.PPC64LE.Memory.quad32",
"Prims.l_imp",
"Vale.AES.GF128.shift_key_1",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.Decls.va_upd_vec"
] | [] | false | false | false | true | true | let va_wp_ShiftKey1_128 (f: poly) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
| (va_get_ok va_s0 /\
(let h:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
let h1:Vale.Math.Poly2_s.poly = Vale.Math.Poly2_s.shift h 1 in
let offset:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset ==
Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add (Vale.Math.Poly2_s.monomial
128)
f)
(- 1))
127) /\
(forall (va_x_v1: quad32) (va_x_v2: quad32) (va_x_v3: quad32).
let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 va_s0)) in
va_get_ok va_sM /\
(let h:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
let h1:Vale.Math.Poly2_s.poly = Vale.Math.Poly2_s.shift h 1 in
let offset:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==>
va_k va_sM (()))) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_codegen_success_ShiftKey1_128 | val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool | val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool | let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ())))))))) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 69,
"end_line": 54,
"start_col": 0,
"start_line": 46
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_pbool_and",
"Vale.PPC64LE.InsVector.va_codegen_success_Vmr",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.AES.PPC64LE.GF128_Mul.va_codegen_success_ShiftLeft128_1",
"Vale.AES.PPC64LE.PolyOps.va_codegen_success_VPolyAnd",
"Vale.PPC64LE.InsVector.va_codegen_success_Vcmpequw",
"Vale.PPC64LE.InsVector.va_codegen_success_Vspltw",
"Vale.AES.PPC64LE.PolyOps.va_codegen_success_VPolyAdd",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_ShiftKey1_128 () =
| (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_pbool_and (va_codegen_success_ShiftLeft128_1 ())
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)
0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4))
(va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 3))
(va_ttrue ())))))))) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_wp_ShiftKey1_gf128_power | val va_wp_ShiftKey1_gf128_power
(h: poly)
(n: nat)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | val va_wp_ShiftKey1_gf128_power
(h: poly)
(n: nat)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | let va_wp_ShiftKey1_gf128_power (h:poly) (n:nat) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in hn == Vale.AES.GHash_BE.g_power h n) /\ (forall (va_x_r10:nat64)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) . let
va_sM = va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_reg 10 va_x_r10 va_s0))))) in va_get_ok va_sM /\ (let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) ==>
va_k va_sM (()))) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 281,
"start_col": 0,
"start_line": 272
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ())))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(()))))))))))))))))))
val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
h: Vale.Math.Poly2_s.poly ->
n: Prims.nat ->
va_s0: Vale.PPC64LE.Decls.va_state ->
va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.Math.Poly2_s.poly",
"Prims.nat",
"Vale.PPC64LE.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Prims.eq2",
"Vale.AES.GHash_BE.g_power",
"Vale.Math.Poly2.Bits_s.of_quad32",
"Vale.PPC64LE.Decls.va_get_vec",
"Prims.l_Forall",
"Vale.PPC64LE.Memory.nat64",
"Vale.PPC64LE.Memory.quad32",
"Prims.l_imp",
"Vale.AES.GHash_BE.gf128_power",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.Decls.va_upd_vec",
"Vale.PPC64LE.Decls.va_upd_reg"
] | [] | false | false | false | true | true | let va_wp_ShiftKey1_gf128_power
(h: poly)
(n: nat)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 =
| (va_get_ok va_s0 /\
(let hn:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
hn == Vale.AES.GHash_BE.g_power h n) /\
(forall (va_x_r10: nat64)
(va_x_v1: quad32)
(va_x_v2: quad32)
(va_x_v3: quad32)
(va_x_v4: quad32)
(va_x_v5: quad32).
let va_sM =
va_upd_vec 5
va_x_v5
(va_upd_vec 4
va_x_v4
(va_upd_vec 3
va_x_v3
(va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_reg 10 va_x_r10 va_s0)))))
in
va_get_ok va_sM /\
(let hn:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) ==>
va_k va_sM (()))) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_code_Gf128_powers | val va_code_Gf128_powers : va_dummy:unit -> Tot va_code | val va_code_Gf128_powers : va_dummy:unit -> Tot va_code | let va_code_Gf128_powers () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vmr (va_op_vec_opr_vec
6) (va_op_vec_opr_vec 1)) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1))
(va_CCons (va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_Store128_byte16_buffer
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) Secret) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vmr
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Gf128MulRev128 ()) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_CCons
(va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16)
(va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CNil
()))))))))))))))) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 328,
"start_col": 0,
"start_line": 315
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ())))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(()))))))))))))))))))
val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_gf128_power (h:poly) (n:nat) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in hn == Vale.AES.GHash_BE.g_power h n) /\ (forall (va_x_r10:nat64)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) . let
va_sM = va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_reg 10 va_x_r10 va_s0))))) in va_get_ok va_sM /\ (let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) ==>
va_k va_sM (())))
val va_wpProof_ShiftKey1_gf128_power : h:poly -> n:nat -> va_s0:va_state -> va_k:(va_state -> unit
-> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_gf128_power h n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_gf128_power h n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_gf128_power (va_code_ShiftKey1_gf128_power ()) va_s0 h n
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_gf128_power (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(va_QProc (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) (va_wp_ShiftKey1_gf128_power h n)
(va_wpProof_ShiftKey1_gf128_power h n))
//--
//-- Gf128_powers
val va_code_Gf128_powers : va_dummy:unit -> Tot va_code | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Vale.PPC64LE.InsBasic.va_code_LoadImm64",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.PPC64LE.InsVector.va_code_Load128_byte16_buffer_index",
"Vale.PPC64LE.Decls.va_op_heaplet_mem_heaplet",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.PPC64LE.InsVector.va_code_Vmr",
"Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_gf128_power",
"Vale.PPC64LE.InsVector.va_code_Store128_byte16_buffer",
"Vale.AES.PPC64LE.GF128_Mul.va_code_Gf128MulRev128",
"Vale.PPC64LE.InsVector.va_code_Store128_byte16_buffer_index",
"Vale.PPC64LE.Decls.va_CNil",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_Gf128_powers () =
| (va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 32)
(va_CCons (va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3)
(va_op_reg_opr_reg 10)
Secret)
(va_CCons (va_code_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1))
(va_CCons (va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1))
(va_CCons (va_code_ShiftKey1_gf128_power ())
(va_CCons (va_code_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3)
Secret)
(va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6))
(va_CCons (va_code_Vmr (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6))
(va_CCons (va_code_Gf128MulRev128 ())
(va_CCons (va_code_Vmr (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 1))
(va_CCons (va_code_ShiftKey1_gf128_power ())
(va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10)
16)
(va_CCons (va_code_Store128_byte16_buffer_index (
va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3)
(va_op_reg_opr_reg 10)
Secret)
(va_CNil ()))))))))))))))) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_gf128_power | val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code | val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code | let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
())))))))))))) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 18,
"end_line": 180,
"start_col": 0,
"start_line": 171
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Vale.PPC64LE.InsVector.va_code_Vspltisw",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.PPC64LE.InsBasic.va_code_LoadImmShl64",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Prims.op_Minus",
"Vale.PPC64LE.InsVector.va_code_Mtvsrws",
"Vale.PPC64LE.InsVector.va_code_Vsldoi",
"Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_128",
"Vale.PPC64LE.Decls.va_CNil",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_ShiftKey1_gf128_power () =
| (va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0)
(va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 2) 1)
(va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (- 15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10))
(va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (- 32768))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10))
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 1)
8)
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1)
12)
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 2)
4)
(va_CCons (va_code_ShiftKey1_128 ()) (va_CNil ())))))))))))) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_codegen_success_Gf128_powers | val va_codegen_success_Gf128_powers : va_dummy:unit -> Tot va_pbool | val va_codegen_success_Gf128_powers : va_dummy:unit -> Tot va_pbool | let va_codegen_success_Gf128_powers () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Gf128MulRev128 ()) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and (va_codegen_success_LoadImm64
(va_op_reg_opr_reg 10) 16) (va_pbool_and (va_codegen_success_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
10) Secret) (va_ttrue ())))))))))))))) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 42,
"end_line": 347,
"start_col": 0,
"start_line": 332
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ())))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(()))))))))))))))))))
val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_gf128_power (h:poly) (n:nat) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in hn == Vale.AES.GHash_BE.g_power h n) /\ (forall (va_x_r10:nat64)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) . let
va_sM = va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_reg 10 va_x_r10 va_s0))))) in va_get_ok va_sM /\ (let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) ==>
va_k va_sM (())))
val va_wpProof_ShiftKey1_gf128_power : h:poly -> n:nat -> va_s0:va_state -> va_k:(va_state -> unit
-> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_gf128_power h n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_gf128_power h n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_gf128_power (va_code_ShiftKey1_gf128_power ()) va_s0 h n
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_gf128_power (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(va_QProc (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) (va_wp_ShiftKey1_gf128_power h n)
(va_wpProof_ShiftKey1_gf128_power h n))
//--
//-- Gf128_powers
val va_code_Gf128_powers : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gf128_powers () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vmr (va_op_vec_opr_vec
6) (va_op_vec_opr_vec 1)) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1))
(va_CCons (va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_Store128_byte16_buffer
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) Secret) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vmr
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Gf128MulRev128 ()) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_CCons
(va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16)
(va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CNil
())))))))))))))))
val va_codegen_success_Gf128_powers : va_dummy:unit -> Tot va_pbool | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_pbool_and",
"Vale.PPC64LE.InsBasic.va_codegen_success_LoadImm64",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.PPC64LE.InsVector.va_codegen_success_Load128_byte16_buffer_index",
"Vale.PPC64LE.Decls.va_op_heaplet_mem_heaplet",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.PPC64LE.InsVector.va_codegen_success_Vmr",
"Vale.AES.PPC64LE.GF128_Init.va_codegen_success_ShiftKey1_gf128_power",
"Vale.PPC64LE.InsVector.va_codegen_success_Store128_byte16_buffer",
"Vale.AES.PPC64LE.GF128_Mul.va_codegen_success_Gf128MulRev128",
"Vale.PPC64LE.InsVector.va_codegen_success_Store128_byte16_buffer_index",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_Gf128_powers () =
| (va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32)
(va_pbool_and (va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3)
(va_op_reg_opr_reg 10)
Secret)
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1))
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1))
(va_pbool_and (va_codegen_success_ShiftKey1_gf128_power ())
(va_pbool_and (va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet
1)
(va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3)
Secret)
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6))
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 6))
(va_pbool_and (va_codegen_success_Gf128MulRev128 ())
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 1))
(va_pbool_and (va_codegen_success_ShiftKey1_gf128_power ())
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg
10)
16)
(va_pbool_and (va_codegen_success_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3)
(va_op_reg_opr_reg 10)
Secret)
(va_ttrue ())))))))))))))) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_codegen_success_Keyhash_init | val va_codegen_success_Keyhash_init : alg:algorithm -> Tot va_pbool | val va_codegen_success_Keyhash_init : alg:algorithm -> Tot va_pbool | let va_codegen_success_Keyhash_init alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (va_codegen_success_Vspltisw
(va_op_vec_opr_vec 0) 0) (va_pbool_and (va_codegen_success_AESEncryptBlock alg) (va_pbool_and
(va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Gf128_powers ()) (va_pbool_and (va_codegen_success_DestroyHeaplets ())
(va_ttrue ())))))))) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 24,
"end_line": 508,
"start_col": 0,
"start_line": 501
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ())))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(()))))))))))))))))))
val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_gf128_power (h:poly) (n:nat) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in hn == Vale.AES.GHash_BE.g_power h n) /\ (forall (va_x_r10:nat64)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) . let
va_sM = va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_reg 10 va_x_r10 va_s0))))) in va_get_ok va_sM /\ (let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) ==>
va_k va_sM (())))
val va_wpProof_ShiftKey1_gf128_power : h:poly -> n:nat -> va_s0:va_state -> va_k:(va_state -> unit
-> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_gf128_power h n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_gf128_power h n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_gf128_power (va_code_ShiftKey1_gf128_power ()) va_s0 h n
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_gf128_power (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(va_QProc (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) (va_wp_ShiftKey1_gf128_power h n)
(va_wpProof_ShiftKey1_gf128_power h n))
//--
//-- Gf128_powers
val va_code_Gf128_powers : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gf128_powers () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vmr (va_op_vec_opr_vec
6) (va_op_vec_opr_vec 1)) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1))
(va_CCons (va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_Store128_byte16_buffer
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) Secret) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vmr
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Gf128MulRev128 ()) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_CCons
(va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16)
(va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CNil
())))))))))))))))
val va_codegen_success_Gf128_powers : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gf128_powers () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Gf128MulRev128 ()) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and (va_codegen_success_LoadImm64
(va_op_reg_opr_reg 10) 16) (va_pbool_and (va_codegen_success_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
10) Secret) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gf128_powers (va_mods:va_mods_t) (h:poly) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gf128_powers ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 147 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 148 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 2) (fun (va_s:va_state) _ -> let
(va_arg18:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_1 va_arg18) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 150 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 151 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 152 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 153 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret hkeys_b 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 155 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 156 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 157 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Gf128MulRev128 ()) (fun (va_s:va_state) _ -> let (va_arg17:Vale.Math.Poly2_s.poly) =
h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 158 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_n va_arg17 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 159 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 160 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 161 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 162 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 1) (va_QEmpty (()))))))))))))))))))
val va_lemma_Gf128_powers : va_b0:va_code -> va_s0:va_state -> h:poly -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gf128_powers ()) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) hkeys_b 3
(va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) /\ va_state_eq va_sM
(va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gf128_powers va_b0 va_s0 h hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gf128_powers va_mods h hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gf128_powers ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 128 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 141 column 61 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 142 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 143 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 1 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 2) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 145 column 84 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gf128_powers (h:poly) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg
3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap)
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32)
(va_x_v4:quad32) (va_x_v5:quad32) (va_x_v6:quad32) . let va_sM = va_upd_vec 6 va_x_v6
(va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem_heaplet 1
va_x_heap1 (va_upd_mem va_x_mem va_s0))))))))) in va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) ==> va_k va_sM (())))
val va_wpProof_Gf128_powers : h:poly -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state ->
unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gf128_powers h hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gf128_powers ()) ([va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gf128_powers h hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gf128_powers (va_code_Gf128_powers ()) va_s0 h hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gf128_powers (h:poly) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Gf128_powers
())) =
(va_QProc (va_code_Gf128_powers ()) ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem])
(va_wp_Gf128_powers h hkeys_b) (va_wpProof_Gf128_powers h hkeys_b))
//--
//-- Keyhash_init
[@ "opaque_to_smt" va_qattr]
let va_code_Keyhash_init alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0)
0) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10)
32) (va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons
(va_code_Gf128_powers ()) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_DestroyHeaplets
()) (va_CNil ())))))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | alg: Vale.AES.AES_common_s.algorithm -> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Decls.va_pbool_and",
"Vale.PPC64LE.InsMem.va_codegen_success_CreateHeaplets",
"Vale.PPC64LE.InsVector.va_codegen_success_Vspltisw",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.AES.PPC64LE.AES.va_codegen_success_AESEncryptBlock",
"Vale.PPC64LE.InsBasic.va_codegen_success_LoadImm64",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.PPC64LE.InsVector.va_codegen_success_Store128_byte16_buffer_index",
"Vale.PPC64LE.Decls.va_op_heaplet_mem_heaplet",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.AES.PPC64LE.GF128_Init.va_codegen_success_Gf128_powers",
"Vale.PPC64LE.InsMem.va_codegen_success_DestroyHeaplets",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_Keyhash_init alg =
| (va_pbool_and (va_codegen_success_CreateHeaplets ())
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 0) 0)
(va_pbool_and (va_codegen_success_AESEncryptBlock alg)
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32)
(va_pbool_and (va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet
1)
(va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 3)
(va_op_reg_opr_reg 10)
Secret)
(va_pbool_and (va_codegen_success_Gf128_powers ())
(va_pbool_and (va_codegen_success_DestroyHeaplets ()) (va_ttrue ())))))))) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_code_Keyhash_init | val va_code_Keyhash_init : alg:algorithm -> Tot va_code | val va_code_Keyhash_init : alg:algorithm -> Tot va_code | let va_code_Keyhash_init alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0)
0) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10)
32) (va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons
(va_code_Gf128_powers ()) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_DestroyHeaplets
()) (va_CNil ())))))))))) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 498,
"start_col": 0,
"start_line": 492
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ())))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(()))))))))))))))))))
val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_gf128_power (h:poly) (n:nat) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in hn == Vale.AES.GHash_BE.g_power h n) /\ (forall (va_x_r10:nat64)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) . let
va_sM = va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_reg 10 va_x_r10 va_s0))))) in va_get_ok va_sM /\ (let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) ==>
va_k va_sM (())))
val va_wpProof_ShiftKey1_gf128_power : h:poly -> n:nat -> va_s0:va_state -> va_k:(va_state -> unit
-> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_gf128_power h n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_gf128_power h n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_gf128_power (va_code_ShiftKey1_gf128_power ()) va_s0 h n
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_gf128_power (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(va_QProc (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) (va_wp_ShiftKey1_gf128_power h n)
(va_wpProof_ShiftKey1_gf128_power h n))
//--
//-- Gf128_powers
val va_code_Gf128_powers : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gf128_powers () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vmr (va_op_vec_opr_vec
6) (va_op_vec_opr_vec 1)) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1))
(va_CCons (va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_Store128_byte16_buffer
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) Secret) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vmr
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Gf128MulRev128 ()) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_CCons
(va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16)
(va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CNil
())))))))))))))))
val va_codegen_success_Gf128_powers : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gf128_powers () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Gf128MulRev128 ()) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and (va_codegen_success_LoadImm64
(va_op_reg_opr_reg 10) 16) (va_pbool_and (va_codegen_success_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
10) Secret) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gf128_powers (va_mods:va_mods_t) (h:poly) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gf128_powers ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 147 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 148 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 2) (fun (va_s:va_state) _ -> let
(va_arg18:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_1 va_arg18) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 150 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 151 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 152 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 153 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret hkeys_b 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 155 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 156 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 157 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Gf128MulRev128 ()) (fun (va_s:va_state) _ -> let (va_arg17:Vale.Math.Poly2_s.poly) =
h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 158 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_n va_arg17 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 159 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 160 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 161 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 162 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 1) (va_QEmpty (()))))))))))))))))))
val va_lemma_Gf128_powers : va_b0:va_code -> va_s0:va_state -> h:poly -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gf128_powers ()) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) hkeys_b 3
(va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) /\ va_state_eq va_sM
(va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gf128_powers va_b0 va_s0 h hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gf128_powers va_mods h hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gf128_powers ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 128 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 141 column 61 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 142 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 143 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 1 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 2) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 145 column 84 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gf128_powers (h:poly) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg
3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap)
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32)
(va_x_v4:quad32) (va_x_v5:quad32) (va_x_v6:quad32) . let va_sM = va_upd_vec 6 va_x_v6
(va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem_heaplet 1
va_x_heap1 (va_upd_mem va_x_mem va_s0))))))))) in va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) ==> va_k va_sM (())))
val va_wpProof_Gf128_powers : h:poly -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state ->
unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gf128_powers h hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gf128_powers ()) ([va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gf128_powers h hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gf128_powers (va_code_Gf128_powers ()) va_s0 h hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gf128_powers (h:poly) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Gf128_powers
())) =
(va_QProc (va_code_Gf128_powers ()) ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem])
(va_wp_Gf128_powers h hkeys_b) (va_wpProof_Gf128_powers h hkeys_b))
//--
//-- Keyhash_init | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | alg: Vale.AES.AES_common_s.algorithm -> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Vale.PPC64LE.InsMem.va_code_CreateHeaplets",
"Vale.PPC64LE.InsVector.va_code_Vspltisw",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.AES.PPC64LE.AES.va_code_AESEncryptBlock",
"Vale.PPC64LE.InsBasic.va_code_LoadImm64",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.PPC64LE.InsVector.va_code_Store128_byte16_buffer_index",
"Vale.PPC64LE.Decls.va_op_heaplet_mem_heaplet",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.AES.PPC64LE.GF128_Init.va_code_Gf128_powers",
"Vale.PPC64LE.Decls.va_CNil",
"Vale.PPC64LE.InsMem.va_code_DestroyHeaplets",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_Keyhash_init alg =
| (va_Block (va_CCons (va_code_CreateHeaplets ())
(va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0) 0)
(va_CCons (va_code_AESEncryptBlock alg)
(va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 32)
(va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 3)
(va_op_reg_opr_reg 10)
Secret)
(va_CCons (va_code_Gf128_powers ())
(va_CCons (va_Block (va_CNil ()))
(va_CCons (va_code_DestroyHeaplets ()) (va_CNil ())))))))))) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_wp_Gf128_powers | val va_wp_Gf128_powers
(h: poly)
(hkeys_b: buffer128)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | val va_wp_Gf128_powers
(h: poly)
(hkeys_b: buffer128)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | let va_wp_Gf128_powers (h:poly) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg
3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap)
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32)
(va_x_v4:quad32) (va_x_v5:quad32) (va_x_v6:quad32) . let va_sM = va_upd_vec 6 va_x_v6
(va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem_heaplet 1
va_x_heap1 (va_upd_mem va_x_mem va_s0))))))))) in va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) ==> va_k va_sM (()))) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 98,
"end_line": 459,
"start_col": 0,
"start_line": 440
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ())))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(()))))))))))))))))))
val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_gf128_power (h:poly) (n:nat) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in hn == Vale.AES.GHash_BE.g_power h n) /\ (forall (va_x_r10:nat64)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) . let
va_sM = va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_reg 10 va_x_r10 va_s0))))) in va_get_ok va_sM /\ (let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) ==>
va_k va_sM (())))
val va_wpProof_ShiftKey1_gf128_power : h:poly -> n:nat -> va_s0:va_state -> va_k:(va_state -> unit
-> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_gf128_power h n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_gf128_power h n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_gf128_power (va_code_ShiftKey1_gf128_power ()) va_s0 h n
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_gf128_power (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(va_QProc (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) (va_wp_ShiftKey1_gf128_power h n)
(va_wpProof_ShiftKey1_gf128_power h n))
//--
//-- Gf128_powers
val va_code_Gf128_powers : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gf128_powers () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vmr (va_op_vec_opr_vec
6) (va_op_vec_opr_vec 1)) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1))
(va_CCons (va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_Store128_byte16_buffer
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) Secret) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vmr
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Gf128MulRev128 ()) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_CCons
(va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16)
(va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CNil
())))))))))))))))
val va_codegen_success_Gf128_powers : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gf128_powers () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Gf128MulRev128 ()) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and (va_codegen_success_LoadImm64
(va_op_reg_opr_reg 10) 16) (va_pbool_and (va_codegen_success_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
10) Secret) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gf128_powers (va_mods:va_mods_t) (h:poly) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gf128_powers ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 147 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 148 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 2) (fun (va_s:va_state) _ -> let
(va_arg18:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_1 va_arg18) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 150 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 151 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 152 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 153 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret hkeys_b 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 155 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 156 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 157 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Gf128MulRev128 ()) (fun (va_s:va_state) _ -> let (va_arg17:Vale.Math.Poly2_s.poly) =
h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 158 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_n va_arg17 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 159 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 160 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 161 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 162 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 1) (va_QEmpty (()))))))))))))))))))
val va_lemma_Gf128_powers : va_b0:va_code -> va_s0:va_state -> h:poly -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gf128_powers ()) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) hkeys_b 3
(va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) /\ va_state_eq va_sM
(va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gf128_powers va_b0 va_s0 h hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gf128_powers va_mods h hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gf128_powers ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 128 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 141 column 61 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 142 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 143 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 1 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 2) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 145 column 84 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM
va_s0;
(va_sM, va_fM) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
h: Vale.Math.Poly2_s.poly ->
hkeys_b: Vale.PPC64LE.Memory.buffer128 ->
va_s0: Vale.PPC64LE.Decls.va_state ->
va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.Math.Poly2_s.poly",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Vale.PPC64LE.Decls.validDstAddrs128",
"Vale.PPC64LE.Decls.va_get_mem_heaplet",
"Vale.PPC64LE.Decls.va_get_reg",
"Vale.PPC64LE.Decls.va_get_mem_layout",
"Vale.Arch.HeapTypes_s.Secret",
"Prims.eq2",
"Vale.Math.Poly2.Bits_s.of_quad32",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.PPC64LE.Decls.buffer128_read",
"Prims.l_Forall",
"Vale.PPC64LE.InsBasic.vale_heap",
"Vale.PPC64LE.Memory.nat64",
"Vale.PPC64LE.Memory.quad32",
"Prims.l_imp",
"Vale.PPC64LE.Decls.modifies_mem",
"Vale.PPC64LE.Decls.loc_buffer",
"Vale.PPC64LE.Memory.vuint128",
"Vale.AES.GHash_BE.gf128_power",
"Vale.PPC64LE.Machine_s.quad32",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.Decls.va_upd_vec",
"Vale.PPC64LE.Decls.va_upd_reg",
"Vale.PPC64LE.Decls.va_upd_mem_heaplet",
"Vale.PPC64LE.Decls.va_upd_mem"
] | [] | false | false | false | true | true | let va_wp_Gf128_powers
(h: poly)
(hkeys_b: buffer128)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 =
| (va_get_ok va_s0 /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg 3 va_s0)
hkeys_b
3
(va_get_mem_layout va_s0)
Secret /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read
hkeys_b
2
(va_get_mem_heaplet 1 va_s0))) ==
h /\
(forall (va_x_mem: vale_heap) (va_x_heap1: vale_heap) (va_x_r10: nat64) (va_x_v0: quad32)
(va_x_v1: quad32) (va_x_v2: quad32) (va_x_v3: quad32) (va_x_v4: quad32) (va_x_v5: quad32)
(va_x_v6: quad32).
let va_sM =
va_upd_vec 6
va_x_v6
(va_upd_vec 5
va_x_v5
(va_upd_vec 4
va_x_v4
(va_upd_vec 3
va_x_v3
(va_upd_vec 2
va_x_v2
(va_upd_vec 1
va_x_v1
(va_upd_vec 0
va_x_v0
(va_upd_reg 10
va_x_r10
(va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0)))
))))))
in
va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b)
(va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read
hkeys_b
0
(va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read
hkeys_b
1
(va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) ==>
va_k va_sM (()))) | false |
Steel.GhostMonotonicHigherReference.fst | Steel.GhostMonotonicHigherReference.intro_pure_full | val intro_pure_full (#opened #a #p #f: _) (r: ref a p) (v: a) (h: history a p {history_val h v f})
: SteelGhostT unit opened (PR.pts_to r h) (fun _ -> pts_to r f v) | val intro_pure_full (#opened #a #p #f: _) (r: ref a p) (v: a) (h: history a p {history_val h v f})
: SteelGhostT unit opened (PR.pts_to r h) (fun _ -> pts_to r f v) | let intro_pure_full #opened #a #p #f
(r:ref a p)
(v:a)
(h:history a p { history_val h v f })
: SteelGhostT unit opened
(PR.pts_to r h)
(fun _ -> pts_to r f v)
= intro_pure #_ #a #p #f r v h;
intro_exists h (pts_to_body r f v) | {
"file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 38,
"end_line": 66,
"start_col": 0,
"start_line": 58
} | (*
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.GhostMonotonicHigherReference
open FStar.Ghost
open FStar.PCM
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.GhostPCMReference
open Steel.FractionalPermission
open Steel.Preorder
module Preorder = FStar.Preorder
module Q = Steel.Preorder
module M = Steel.Memory
module PR = Steel.GhostPCMReference
module A = Steel.Effect.Atomic
open FStar.Real
#set-options "--ide_id_info_off"
let ref a p = PR.ref (history a p) pcm_history
[@@__reduce__]
let pts_to_body #a #p (r:ref a p) (f:perm) (v:a) (h:history a p) =
PR.pts_to r h `star`
pure (history_val h v f)
let pts_to' (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v: a) =
h_exists (pts_to_body r f v)
let pts_to_sl r f v = hp_of (pts_to' r f v)
let intro_pure #opened #a #p #f
(r:ref a p)
(v:a)
(h:history a p { history_val h v f })
: SteelGhostT unit opened
(PR.pts_to r h)
(fun _ -> pts_to_body r f v h)
= A.intro_pure (history_val h v f) | {
"checked_file": "/",
"dependencies": [
"Steel.Preorder.fst.checked",
"Steel.Memory.fsti.checked",
"Steel.GhostPCMReference.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.GhostMonotonicHigherReference.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Real",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Effect.Atomic",
"short_module": "A"
},
{
"abbrev": true,
"full_module": "Steel.GhostPCMReference",
"short_module": "PR"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Steel.Preorder",
"short_module": "Q"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"abbrev": false,
"full_module": "Steel.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.GhostPCMReference",
"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.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"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": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
r: Steel.GhostMonotonicHigherReference.ref a p ->
v: a ->
h: Steel.Preorder.history a p {Steel.Preorder.history_val h (FStar.Ghost.hide v) f}
-> Steel.Effect.Atomic.SteelGhostT Prims.unit | Steel.Effect.Atomic.SteelGhostT | [] | [] | [
"Steel.Memory.inames",
"FStar.Preorder.preorder",
"Steel.FractionalPermission.perm",
"Steel.GhostMonotonicHigherReference.ref",
"Steel.Preorder.history",
"Steel.Preorder.history_val",
"FStar.Ghost.hide",
"Steel.Effect.Atomic.intro_exists",
"Steel.GhostMonotonicHigherReference.pts_to_body",
"Prims.unit",
"Steel.GhostMonotonicHigherReference.intro_pure",
"Steel.GhostPCMReference.pts_to",
"Steel.Preorder.pcm_history",
"Steel.GhostMonotonicHigherReference.pts_to",
"Steel.Effect.Common.vprop"
] | [] | false | true | false | false | false | let intro_pure_full #opened #a #p #f (r: ref a p) (v: a) (h: history a p {history_val h v f})
: SteelGhostT unit opened (PR.pts_to r h) (fun _ -> pts_to r f v) =
| intro_pure #_ #a #p #f r v h;
intro_exists h (pts_to_body r f v) | false |
Steel.ST.Array.fst | Steel.ST.Array.pts_to_range_index | val pts_to_range_index
(#elt: Type0)
(#p: P.perm)
(#s: Ghost.erased (Seq.seq elt))
(a: array elt)
(i: Ghost.erased nat)
(m: US.t)
(j: Ghost.erased nat)
: ST elt
(pts_to_range a i j p s)
(fun _ -> pts_to_range a i j p s)
(i <= US.v m /\ US.v m < j)
(fun res ->
i <= US.v m /\ US.v m < j /\
Seq.length s == j - i /\
res == Seq.index s (US.v m - i)
) | val pts_to_range_index
(#elt: Type0)
(#p: P.perm)
(#s: Ghost.erased (Seq.seq elt))
(a: array elt)
(i: Ghost.erased nat)
(m: US.t)
(j: Ghost.erased nat)
: ST elt
(pts_to_range a i j p s)
(fun _ -> pts_to_range a i j p s)
(i <= US.v m /\ US.v m < j)
(fun res ->
i <= US.v m /\ US.v m < j /\
Seq.length s == j - i /\
res == Seq.index s (US.v m - i)
) | let pts_to_range_index
#elt #p #s a i m j
= pts_to_range_split a i (US.v m) j;
let s1 = elim_exists () in
let s2 = elim_exists () in
elim_pure _;
let ga' = pts_to_range_elim' a (US.v m) j p s2 in
let a' = array_slice_impl a m j () in
vpattern_rewrite #_ #(array elt) #ga' (fun ga' -> pts_to ga' _ _) a';
let res = index a' 0sz in
pts_to_range_intro' a (US.v m) j p a' s2;
pts_to_range_join a i (US.v m) j;
vpattern_rewrite (pts_to_range a i j p) (Ghost.reveal s);
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": 684,
"start_col": 0,
"start_line": 671
} | (*
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 ()
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
let array_slice
(#elt: Type0)
(a: array elt)
(i j: nat)
(sq: squash (i <= j /\ j <= length a))
: Ghost (array elt)
(requires True)
(ensures (fun a' -> length a' == j - i))
= length_fits a;
split_l (split_r a (US.uint_to_t i)) (US.uint_to_t (j - i))
[@@__reduce__]
let pts_to_range_body
(#elt: Type0) (a: array elt) (i j: nat)
(p: P.perm)
(s: Seq.seq elt)
(sq: squash (i <= j /\ j <= length a))
: Tot vprop
= pts_to (array_slice a i j sq) p s
let pts_to_range
(#elt: Type0) (a: array elt) (i j: nat)
(p: P.perm)
([@@@ smt_fallback ] s: Seq.seq elt)
: Tot vprop
= exists_ (pts_to_range_body a i j p s)
let pts_to_range_intro'
(#opened: _)
(#elt: Type0) (a: array elt) (i j: nat)
(p: P.perm)
(a': array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a' p s)
(fun _ -> pts_to_range a i j p s)
(i <= j /\ j <= length a /\
a' == array_slice a i j ()
)
(fun _ -> True)
= let sq : squash (i <= j /\ j <= length a) = () in
rewrite (pts_to a' p s) (pts_to (array_slice a i j sq) p s);
rewrite (exists_ (pts_to_range_body a i j p s)) (pts_to_range a i j p s)
let pts_to_range_elim'
(#opened: _)
(#elt: Type0) (a: array elt) (i j: nat)
(p: P.perm)
(s: Seq.seq elt)
: STGhost (Ghost.erased (array elt)) opened
(pts_to_range a i j p s)
(fun a' -> pts_to a' p s)
True
(fun a' -> i <= j /\ j <= length a /\
Ghost.reveal a' == array_slice a i j ()
)
= rewrite (pts_to_range a i j p s) (exists_ (pts_to_range_body a i j p s));
let _ = elim_exists () in
vpattern_replace_erased (fun a' -> pts_to a' p s)
let pts_to_range_prop
a i j p s
= let a' = pts_to_range_elim' a i j p s in
pts_to_length a' s;
pts_to_range_intro' a i j p a' s
let pts_to_range_intro
a p s
= ptr_shift_zero (ptr_of a);
pts_to_range_intro' a 0 (length a) p a s
let pts_to_range_elim
a p s
= ptr_shift_zero (ptr_of a);
let a' = pts_to_range_elim' a 0 (length a) p s in
vpattern_rewrite (fun a' -> pts_to a' _ _) a
let pts_to_range_split
#_ #_ #p #s a i m j
= length_fits a;
pts_to_range_prop a i j p s;
let a' = pts_to_range_elim' a i j p s in
let mi = US.uint_to_t (m - i) in
ptr_shift_add (ptr_of a) (US.uint_to_t i) mi;
let _ = ghost_split a' mi in
pts_to_range_intro' a m j p (split_r a' mi) _;
pts_to_range_intro' a i m p (split_l a' mi) _;
noop ()
let pts_to_range_join
#_ #_ #p #s1 #s2 a i m j
= length_fits a;
pts_to_range_prop a i m p s1;
pts_to_range_prop a m j p s2;
let a1 = pts_to_range_elim' a i m p s1 in
let a2 = pts_to_range_elim' a m j p s2 in
ghost_join a1 a2 ();
pts_to_range_intro' a i j p _ _
inline_for_extraction
[@@noextract_to "krml"]
let array_slice_impl
(#elt: Type0)
(a: array elt)
(i: US.t)
(j: Ghost.erased nat)
(sq: squash (US.v i <= j /\ j <= length a))
: Pure (array elt)
(requires True)
(ensures (fun a' -> a' == array_slice a (US.v i) j sq))
= length_fits a;
split_l (split_r a i) (US.uint_to_t (j - US.v i)) | {
"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 |
a: Steel.ST.Array.array elt ->
i: FStar.Ghost.erased Prims.nat ->
m: FStar.SizeT.t ->
j: FStar.Ghost.erased Prims.nat
-> Steel.ST.Effect.ST elt | Steel.ST.Effect.ST | [] | [] | [
"Steel.FractionalPermission.perm",
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Steel.ST.Array.array",
"Prims.nat",
"FStar.SizeT.t",
"Steel.ST.Util.return",
"FStar.Ghost.hide",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.empty",
"Steel.ST.Array.pts_to_range",
"FStar.Ghost.reveal",
"Steel.Effect.Common.vprop",
"Prims.unit",
"Steel.ST.Util.vpattern_rewrite",
"FStar.Seq.Base.append",
"Steel.ST.Array.pts_to_range_join",
"FStar.SizeT.v",
"Steel.ST.Array.pts_to_range_intro'",
"Steel.ST.Array.index",
"FStar.SizeT.__uint_to_t",
"Steel.ST.Array.pts_to",
"Steel.ST.Array.array_slice_impl",
"Steel.ST.Array.pts_to_range_elim'",
"Steel.ST.Util.elim_pure",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Steel.ST.Array.length",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Prims.op_Subtraction",
"FStar.Seq.Base.slice",
"Steel.ST.Util.elim_exists",
"Steel.Effect.Common.VStar",
"Steel.ST.Util.pure",
"Steel.ST.Util.exists_",
"Steel.ST.Array.pts_to_range_split"
] | [] | false | true | false | false | false | let pts_to_range_index #elt #p #s a i m j =
| pts_to_range_split a i (US.v m) j;
let s1 = elim_exists () in
let s2 = elim_exists () in
elim_pure _;
let ga' = pts_to_range_elim' a (US.v m) j p s2 in
let a' = array_slice_impl a m j () in
vpattern_rewrite #_ #(array elt) #ga' (fun ga' -> pts_to ga' _ _) a';
let res = index a' 0sz in
pts_to_range_intro' a (US.v m) j p a' s2;
pts_to_range_join a i (US.v m) j;
vpattern_rewrite (pts_to_range a i j p) (Ghost.reveal s);
return res | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_quick_ShiftKey1_128 | val va_quick_ShiftKey1_128 (f: poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) | val va_quick_ShiftKey1_128 (f: poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) | let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f)) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 57,
"end_line": 165,
"start_col": 0,
"start_line": 163
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | f: Vale.Math.Poly2_s.poly
-> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit
(Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_128 ()) | Prims.Tot | [
"total"
] | [] | [
"Vale.Math.Poly2_s.poly",
"Vale.PPC64LE.QuickCode.va_QProc",
"Prims.unit",
"Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_128",
"Prims.Cons",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.va_Mod_vec",
"Prims.Nil",
"Vale.AES.PPC64LE.GF128_Init.va_wp_ShiftKey1_128",
"Vale.AES.PPC64LE.GF128_Init.va_wpProof_ShiftKey1_128",
"Vale.PPC64LE.QuickCode.va_quickCode"
] | [] | false | false | false | false | false | let va_quick_ShiftKey1_128 (f: poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
| (va_QProc (va_code_ShiftKey1_128 ())
([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f)
(va_wpProof_ShiftKey1_128 f)) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_quick_Gf128_powers | val va_quick_Gf128_powers (h: poly) (hkeys_b: buffer128)
: (va_quickCode unit (va_code_Gf128_powers ())) | val va_quick_Gf128_powers (h: poly) (hkeys_b: buffer128)
: (va_quickCode unit (va_code_Gf128_powers ())) | let va_quick_Gf128_powers (h:poly) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Gf128_powers
())) =
(va_QProc (va_code_Gf128_powers ()) ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem])
(va_wp_Gf128_powers h hkeys_b) (va_wpProof_Gf128_powers h hkeys_b)) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 71,
"end_line": 487,
"start_col": 0,
"start_line": 483
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ())))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(()))))))))))))))))))
val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_gf128_power (h:poly) (n:nat) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in hn == Vale.AES.GHash_BE.g_power h n) /\ (forall (va_x_r10:nat64)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) . let
va_sM = va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_reg 10 va_x_r10 va_s0))))) in va_get_ok va_sM /\ (let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) ==>
va_k va_sM (())))
val va_wpProof_ShiftKey1_gf128_power : h:poly -> n:nat -> va_s0:va_state -> va_k:(va_state -> unit
-> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_gf128_power h n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_gf128_power h n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_gf128_power (va_code_ShiftKey1_gf128_power ()) va_s0 h n
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_gf128_power (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(va_QProc (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) (va_wp_ShiftKey1_gf128_power h n)
(va_wpProof_ShiftKey1_gf128_power h n))
//--
//-- Gf128_powers
val va_code_Gf128_powers : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gf128_powers () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vmr (va_op_vec_opr_vec
6) (va_op_vec_opr_vec 1)) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1))
(va_CCons (va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_Store128_byte16_buffer
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) Secret) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vmr
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Gf128MulRev128 ()) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_CCons
(va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16)
(va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CNil
())))))))))))))))
val va_codegen_success_Gf128_powers : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gf128_powers () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Gf128MulRev128 ()) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and (va_codegen_success_LoadImm64
(va_op_reg_opr_reg 10) 16) (va_pbool_and (va_codegen_success_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
10) Secret) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gf128_powers (va_mods:va_mods_t) (h:poly) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gf128_powers ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 147 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 148 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 2) (fun (va_s:va_state) _ -> let
(va_arg18:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_1 va_arg18) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 150 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 151 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 152 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 153 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret hkeys_b 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 155 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 156 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 157 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Gf128MulRev128 ()) (fun (va_s:va_state) _ -> let (va_arg17:Vale.Math.Poly2_s.poly) =
h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 158 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_n va_arg17 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 159 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 160 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 161 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 162 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 1) (va_QEmpty (()))))))))))))))))))
val va_lemma_Gf128_powers : va_b0:va_code -> va_s0:va_state -> h:poly -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gf128_powers ()) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) hkeys_b 3
(va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) /\ va_state_eq va_sM
(va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gf128_powers va_b0 va_s0 h hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gf128_powers va_mods h hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gf128_powers ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 128 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 141 column 61 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 142 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 143 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 1 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 2) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 145 column 84 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gf128_powers (h:poly) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg
3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap)
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32)
(va_x_v4:quad32) (va_x_v5:quad32) (va_x_v6:quad32) . let va_sM = va_upd_vec 6 va_x_v6
(va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem_heaplet 1
va_x_heap1 (va_upd_mem va_x_mem va_s0))))))))) in va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) ==> va_k va_sM (())))
val va_wpProof_Gf128_powers : h:poly -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state ->
unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gf128_powers h hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gf128_powers ()) ([va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gf128_powers h hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gf128_powers (va_code_Gf128_powers ()) va_s0 h hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: Vale.Math.Poly2_s.poly -> hkeys_b: Vale.PPC64LE.Memory.buffer128
-> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit
(Vale.AES.PPC64LE.GF128_Init.va_code_Gf128_powers ()) | Prims.Tot | [
"total"
] | [] | [
"Vale.Math.Poly2_s.poly",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.QuickCode.va_QProc",
"Prims.unit",
"Vale.AES.PPC64LE.GF128_Init.va_code_Gf128_powers",
"Prims.Cons",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.va_Mod_vec",
"Vale.PPC64LE.QuickCode.va_Mod_reg",
"Vale.PPC64LE.QuickCode.va_Mod_mem_heaplet",
"Vale.PPC64LE.QuickCode.va_Mod_mem",
"Prims.Nil",
"Vale.AES.PPC64LE.GF128_Init.va_wp_Gf128_powers",
"Vale.AES.PPC64LE.GF128_Init.va_wpProof_Gf128_powers",
"Vale.PPC64LE.QuickCode.va_quickCode"
] | [] | false | false | false | false | false | let va_quick_Gf128_powers (h: poly) (hkeys_b: buffer128)
: (va_quickCode unit (va_code_Gf128_powers ())) =
| (va_QProc (va_code_Gf128_powers ())
([
va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem
])
(va_wp_Gf128_powers h hkeys_b)
(va_wpProof_Gf128_powers h hkeys_b)) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_qcode_ShiftKey1_128 | val va_qcode_ShiftKey1_128 (va_mods: va_mods_t) (f: poly)
: (va_quickCode unit (va_code_ShiftKey1_128 ())) | val va_qcode_ShiftKey1_128 (va_mods: va_mods_t) (f: poly)
: (va_quickCode unit (va_code_ShiftKey1_128 ())) | let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (())))))))))))))))) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 94,
"start_col": 0,
"start_line": 57
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ())))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | va_mods: Vale.PPC64LE.QuickCode.va_mods_t -> f: Vale.Math.Poly2_s.poly
-> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit
(Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_128 ()) | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCode.va_mods_t",
"Vale.Math.Poly2_s.poly",
"Vale.PPC64LE.QuickCodes.qblock",
"Prims.unit",
"Prims.Cons",
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.InsVector.va_code_Vmr",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.AES.PPC64LE.GF128_Mul.va_code_ShiftLeft128_1",
"Vale.AES.PPC64LE.PolyOps.va_code_VPolyAnd",
"Vale.PPC64LE.InsVector.va_code_Vcmpequw",
"Vale.PPC64LE.InsVector.va_code_Vspltw",
"Vale.AES.PPC64LE.PolyOps.va_code_VPolyAdd",
"Prims.Nil",
"Vale.PPC64LE.Machine_s.precode",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.va_QSeq",
"Vale.PPC64LE.QuickCodes.va_range1",
"Vale.PPC64LE.InsVector.va_quick_Vmr",
"Vale.PPC64LE.QuickCodes.va_QBind",
"Vale.AES.PPC64LE.GF128_Mul.va_quick_ShiftLeft128_1",
"Vale.PPC64LE.QuickCodes.va_qPURE",
"Prims.pure_post",
"Prims.l_and",
"Prims.l_True",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.eq2",
"Vale.Math.Poly2.Bits_s.of_quad32",
"Vale.Math.Poly2.Bits_s.to_quad32",
"Vale.Math.Poly2.mask",
"Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask",
"Prims.bool",
"Vale.Math.Poly2_s.poly_index",
"Vale.Math.Poly2_s.shift",
"Prims.op_AmpAmp",
"Prims.op_Subtraction",
"Prims.op_GreaterThanOrEqual",
"Vale.Math.Poly2.lemma_shift_define_i",
"Vale.AES.PPC64LE.PolyOps.va_quick_VPolyAnd",
"Vale.PPC64LE.InsVector.va_quick_Vcmpequw",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.Math.Poly2_s.degree",
"Prims.op_Equality",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Math.Poly2.poly_and",
"Vale.Math.Poly2_s.monomial",
"Vale.AES.GF128.lemma_test_high_bit",
"Vale.PPC64LE.InsVector.va_quick_Vspltw",
"Vale.Def.Words_s.Mkfour",
"Vale.Math.Poly2_s.zero",
"Vale.Def.Words_s.four",
"Vale.Math.Poly2.Words.lemma_quad32_zero",
"Vale.Math.Poly2.ones",
"Vale.Math.Poly2.Words.lemma_quad32_ones",
"Prims.nat",
"Vale.Math.Poly2.Lemmas.lemma_and_consts",
"Vale.AES.PPC64LE.PolyOps.va_quick_VPolyAdd",
"Vale.PPC64LE.QuickCodes.va_QEmpty",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.Decls.va_get_vec",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCode.va_quickCode",
"Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_128"
] | [] | false | false | false | false | false | let va_qcode_ShiftKey1_128 (va_mods: va_mods_t) (f: poly)
: (va_quickCode unit (va_code_ShiftKey1_128 ())) =
| (qblock va_mods
(fun (va_s: va_state) ->
let va_old_s:va_state = va_s in
let h:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in
let h1:Vale.Math.Poly2_s.poly = Vale.Math.Poly2_s.shift h 1 in
let offset:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h)
(fun (va_s: va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_: unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1)
(va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_: unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 5))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 5))
(fun (va_s: va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_: unit) -> Vale.AES.GF128.lemma_test_high_bit h)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)
0)
(fun (va_s: va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_: unit) ->
Vale.Math.Poly2.Words.lemma_quad32_zero ())
(va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_: unit) ->
Vale.Math.Poly2.Words.lemma_quad32_ones ())
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4))
(fun (va_s: va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_: unit) ->
Vale.Math.Poly2.Lemmas.lemma_and_consts
())
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec
1)
(va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 3))
(va_QEmpty (())))))))))))))))) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_quick_ShiftKey1_gf128_power | val va_quick_ShiftKey1_gf128_power (h: poly) (n: nat)
: (va_quickCode unit (va_code_ShiftKey1_gf128_power ())) | val va_quick_ShiftKey1_gf128_power (h: poly) (n: nat)
: (va_quickCode unit (va_code_ShiftKey1_gf128_power ())) | let va_quick_ShiftKey1_gf128_power (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(va_QProc (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) (va_wp_ShiftKey1_gf128_power h n)
(va_wpProof_ShiftKey1_gf128_power h n)) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 43,
"end_line": 309,
"start_col": 0,
"start_line": 305
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ())))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(()))))))))))))))))))
val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_gf128_power (h:poly) (n:nat) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in hn == Vale.AES.GHash_BE.g_power h n) /\ (forall (va_x_r10:nat64)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) . let
va_sM = va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_reg 10 va_x_r10 va_s0))))) in va_get_ok va_sM /\ (let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) ==>
va_k va_sM (())))
val va_wpProof_ShiftKey1_gf128_power : h:poly -> n:nat -> va_s0:va_state -> va_k:(va_state -> unit
-> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_gf128_power h n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_gf128_power h n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_gf128_power (va_code_ShiftKey1_gf128_power ()) va_s0 h n
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: Vale.Math.Poly2_s.poly -> n: Prims.nat
-> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit
(Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_gf128_power ()) | Prims.Tot | [
"total"
] | [] | [
"Vale.Math.Poly2_s.poly",
"Prims.nat",
"Vale.PPC64LE.QuickCode.va_QProc",
"Prims.unit",
"Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_gf128_power",
"Prims.Cons",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.va_Mod_vec",
"Vale.PPC64LE.QuickCode.va_Mod_reg",
"Prims.Nil",
"Vale.AES.PPC64LE.GF128_Init.va_wp_ShiftKey1_gf128_power",
"Vale.AES.PPC64LE.GF128_Init.va_wpProof_ShiftKey1_gf128_power",
"Vale.PPC64LE.QuickCode.va_quickCode"
] | [] | false | false | false | false | false | let va_quick_ShiftKey1_gf128_power (h: poly) (n: nat)
: (va_quickCode unit (va_code_ShiftKey1_gf128_power ())) =
| (va_QProc (va_code_ShiftKey1_gf128_power ())
([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10])
(va_wp_ShiftKey1_gf128_power h n)
(va_wpProof_ShiftKey1_gf128_power h n)) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_wpProof_ShiftKey1_gf128_power | val va_wpProof_ShiftKey1_gf128_power : h:poly -> n:nat -> va_s0:va_state -> va_k:(va_state -> unit
-> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_gf128_power h n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) va_s0 va_k ((va_sM,
va_f0, va_g)))) | val va_wpProof_ShiftKey1_gf128_power : h:poly -> n:nat -> va_s0:va_state -> va_k:(va_state -> unit
-> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_gf128_power h n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) va_s0 va_k ((va_sM,
va_f0, va_g)))) | let va_wpProof_ShiftKey1_gf128_power h n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_gf128_power (va_code_ShiftKey1_gf128_power ()) va_s0 h n
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 302,
"start_col": 0,
"start_line": 292
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ())))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(()))))))))))))))))))
val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_gf128_power (h:poly) (n:nat) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in hn == Vale.AES.GHash_BE.g_power h n) /\ (forall (va_x_r10:nat64)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) . let
va_sM = va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_reg 10 va_x_r10 va_s0))))) in va_get_ok va_sM /\ (let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) ==>
va_k va_sM (())))
val va_wpProof_ShiftKey1_gf128_power : h:poly -> n:nat -> va_s0:va_state -> va_k:(va_state -> unit
-> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_gf128_power h n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) va_s0 va_k ((va_sM,
va_f0, va_g)))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
h: Vale.Math.Poly2_s.poly ->
n: Prims.nat ->
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.Math.Poly2_s.poly",
"Prims.nat",
"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",
"Vale.PPC64LE.QuickCode.va_Mod_reg",
"Prims.Nil",
"Prims._assert",
"Vale.PPC64LE.Decls.va_state_eq",
"Vale.PPC64LE.Decls.va_update_vec",
"Vale.PPC64LE.Decls.va_update_reg",
"Vale.PPC64LE.Decls.va_update_ok",
"Vale.PPC64LE.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.PPC64LE.Machine_s.state",
"Vale.AES.PPC64LE.GF128_Init.va_lemma_ShiftKey1_gf128_power",
"Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_gf128_power"
] | [] | false | false | false | false | false | let va_wpProof_ShiftKey1_gf128_power h n va_s0 va_k =
| let va_sM, va_f0 = va_lemma_ShiftKey1_gf128_power (va_code_ShiftKey1_gf128_power ()) va_s0 h n in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM
(va_update_vec 5
va_sM
(va_update_vec 4
va_sM
(va_update_vec 3
va_sM
(va_update_vec 2
va_sM
(va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))
));
va_lemma_norm_mods ([
va_Mod_vec 5;
va_Mod_vec 4;
va_Mod_vec 3;
va_Mod_vec 2;
va_Mod_vec 1;
va_Mod_reg 10
])
va_sM
va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_wpProof_Gf128_powers | val va_wpProof_Gf128_powers : h:poly -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state ->
unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gf128_powers h hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gf128_powers ()) ([va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | val va_wpProof_Gf128_powers : h:poly -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state ->
unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gf128_powers h hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gf128_powers ()) ([va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | let va_wpProof_Gf128_powers h hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gf128_powers (va_code_Gf128_powers ()) va_s0 h hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 480,
"start_col": 0,
"start_line": 470
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ())))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(()))))))))))))))))))
val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_gf128_power (h:poly) (n:nat) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in hn == Vale.AES.GHash_BE.g_power h n) /\ (forall (va_x_r10:nat64)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) . let
va_sM = va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_reg 10 va_x_r10 va_s0))))) in va_get_ok va_sM /\ (let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) ==>
va_k va_sM (())))
val va_wpProof_ShiftKey1_gf128_power : h:poly -> n:nat -> va_s0:va_state -> va_k:(va_state -> unit
-> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_gf128_power h n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_gf128_power h n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_gf128_power (va_code_ShiftKey1_gf128_power ()) va_s0 h n
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_gf128_power (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(va_QProc (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) (va_wp_ShiftKey1_gf128_power h n)
(va_wpProof_ShiftKey1_gf128_power h n))
//--
//-- Gf128_powers
val va_code_Gf128_powers : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gf128_powers () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vmr (va_op_vec_opr_vec
6) (va_op_vec_opr_vec 1)) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1))
(va_CCons (va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_Store128_byte16_buffer
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) Secret) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vmr
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Gf128MulRev128 ()) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_CCons
(va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16)
(va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CNil
())))))))))))))))
val va_codegen_success_Gf128_powers : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gf128_powers () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Gf128MulRev128 ()) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and (va_codegen_success_LoadImm64
(va_op_reg_opr_reg 10) 16) (va_pbool_and (va_codegen_success_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
10) Secret) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gf128_powers (va_mods:va_mods_t) (h:poly) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gf128_powers ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 147 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 148 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 2) (fun (va_s:va_state) _ -> let
(va_arg18:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_1 va_arg18) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 150 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 151 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 152 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 153 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret hkeys_b 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 155 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 156 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 157 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Gf128MulRev128 ()) (fun (va_s:va_state) _ -> let (va_arg17:Vale.Math.Poly2_s.poly) =
h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 158 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_n va_arg17 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 159 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 160 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 161 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 162 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 1) (va_QEmpty (()))))))))))))))))))
val va_lemma_Gf128_powers : va_b0:va_code -> va_s0:va_state -> h:poly -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gf128_powers ()) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) hkeys_b 3
(va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) /\ va_state_eq va_sM
(va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gf128_powers va_b0 va_s0 h hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gf128_powers va_mods h hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gf128_powers ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 128 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 141 column 61 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 142 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 143 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 1 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 2) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 145 column 84 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gf128_powers (h:poly) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg
3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap)
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32)
(va_x_v4:quad32) (va_x_v5:quad32) (va_x_v6:quad32) . let va_sM = va_upd_vec 6 va_x_v6
(va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem_heaplet 1
va_x_heap1 (va_upd_mem va_x_mem va_s0))))))))) in va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) ==> va_k va_sM (())))
val va_wpProof_Gf128_powers : h:poly -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state ->
unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gf128_powers h hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gf128_powers ()) ([va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
h: Vale.Math.Poly2_s.poly ->
hkeys_b: Vale.PPC64LE.Memory.buffer128 ->
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.Math.Poly2_s.poly",
"Vale.PPC64LE.Memory.buffer128",
"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",
"Vale.PPC64LE.QuickCode.va_Mod_reg",
"Vale.PPC64LE.QuickCode.va_Mod_mem_heaplet",
"Vale.PPC64LE.QuickCode.va_Mod_mem",
"Prims.Nil",
"Prims._assert",
"Vale.PPC64LE.Decls.va_state_eq",
"Vale.PPC64LE.Decls.va_update_vec",
"Vale.PPC64LE.Decls.va_update_reg",
"Vale.PPC64LE.Decls.va_update_mem_heaplet",
"Vale.PPC64LE.Decls.va_update_ok",
"Vale.PPC64LE.Decls.va_update_mem",
"Vale.PPC64LE.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.PPC64LE.Machine_s.state",
"Vale.AES.PPC64LE.GF128_Init.va_lemma_Gf128_powers",
"Vale.AES.PPC64LE.GF128_Init.va_code_Gf128_powers"
] | [] | false | false | false | false | false | let va_wpProof_Gf128_powers h hkeys_b va_s0 va_k =
| let va_sM, va_f0 = va_lemma_Gf128_powers (va_code_Gf128_powers ()) va_s0 h hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM
(va_update_vec 6
va_sM
(va_update_vec 5
va_sM
(va_update_vec 4
va_sM
(va_update_vec 3
va_sM
(va_update_vec 2
va_sM
(va_update_vec 1
va_sM
(va_update_vec 0
va_sM
(va_update_reg 10
va_sM
(va_update_mem_heaplet 1
va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))));
va_lemma_norm_mods ([
va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem
])
va_sM
va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_qcode_Keyhash_init | val va_qcode_Keyhash_init
(va_mods: va_mods_t)
(alg: algorithm)
(key: (seq nat32))
(roundkeys_b hkeys_b: buffer128)
: (va_quickCode unit (va_code_Keyhash_init alg)) | val va_qcode_Keyhash_init
(va_mods: va_mods_t)
(alg: algorithm)
(key: (seq nat32))
(roundkeys_b hkeys_b: buffer128)
: (va_quickCode unit (va_code_Keyhash_init alg)) | let va_qcode_Keyhash_init (va_mods:va_mods_t) (alg:algorithm) (key:(seq nat32))
(roundkeys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Keyhash_init alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 192 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 roundkeys_b 0 Secret Immutable; declare_buffer128
hkeys_b 1 Secret Mutable])) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 196 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (fun (va_s:va_state) _ -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 197 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 0 va_s) key (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem_heaplet 0 va_s) roundkeys_b)) roundkeys_b)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 198 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 2) (fun (va_s:va_state) _ ->
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 201 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Gf128_powers (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 0 va_s)) hkeys_b) (fun
(va_s:va_state) _ -> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 203 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
((fun (alg_10591:Vale.AES.AES_common_s.algorithm) (key_10592:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10593:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592) alg key (Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0)) (fun _ -> let (va_arg12:Vale.Def.Types_s.quad32) =
Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0
0 0) in let (va_arg11:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
hkeys_b) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 203 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_hkeys_reqs_pub_priv va_arg11 va_arg12) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (())))))))))))) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 60,
"end_line": 545,
"start_col": 0,
"start_line": 511
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ())))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(()))))))))))))))))))
val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_gf128_power (h:poly) (n:nat) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in hn == Vale.AES.GHash_BE.g_power h n) /\ (forall (va_x_r10:nat64)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) . let
va_sM = va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_reg 10 va_x_r10 va_s0))))) in va_get_ok va_sM /\ (let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) ==>
va_k va_sM (())))
val va_wpProof_ShiftKey1_gf128_power : h:poly -> n:nat -> va_s0:va_state -> va_k:(va_state -> unit
-> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_gf128_power h n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_gf128_power h n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_gf128_power (va_code_ShiftKey1_gf128_power ()) va_s0 h n
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_gf128_power (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(va_QProc (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) (va_wp_ShiftKey1_gf128_power h n)
(va_wpProof_ShiftKey1_gf128_power h n))
//--
//-- Gf128_powers
val va_code_Gf128_powers : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gf128_powers () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vmr (va_op_vec_opr_vec
6) (va_op_vec_opr_vec 1)) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1))
(va_CCons (va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_Store128_byte16_buffer
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) Secret) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vmr
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Gf128MulRev128 ()) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_CCons
(va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16)
(va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CNil
())))))))))))))))
val va_codegen_success_Gf128_powers : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gf128_powers () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Gf128MulRev128 ()) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and (va_codegen_success_LoadImm64
(va_op_reg_opr_reg 10) 16) (va_pbool_and (va_codegen_success_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
10) Secret) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gf128_powers (va_mods:va_mods_t) (h:poly) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gf128_powers ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 147 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 148 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 2) (fun (va_s:va_state) _ -> let
(va_arg18:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_1 va_arg18) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 150 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 151 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 152 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 153 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret hkeys_b 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 155 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 156 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 157 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Gf128MulRev128 ()) (fun (va_s:va_state) _ -> let (va_arg17:Vale.Math.Poly2_s.poly) =
h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 158 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_n va_arg17 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 159 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 160 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 161 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 162 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 1) (va_QEmpty (()))))))))))))))))))
val va_lemma_Gf128_powers : va_b0:va_code -> va_s0:va_state -> h:poly -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gf128_powers ()) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) hkeys_b 3
(va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) /\ va_state_eq va_sM
(va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gf128_powers va_b0 va_s0 h hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gf128_powers va_mods h hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gf128_powers ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 128 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 141 column 61 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 142 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 143 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 1 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 2) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 145 column 84 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gf128_powers (h:poly) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg
3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap)
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32)
(va_x_v4:quad32) (va_x_v5:quad32) (va_x_v6:quad32) . let va_sM = va_upd_vec 6 va_x_v6
(va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem_heaplet 1
va_x_heap1 (va_upd_mem va_x_mem va_s0))))))))) in va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) ==> va_k va_sM (())))
val va_wpProof_Gf128_powers : h:poly -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state ->
unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gf128_powers h hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gf128_powers ()) ([va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gf128_powers h hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gf128_powers (va_code_Gf128_powers ()) va_s0 h hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gf128_powers (h:poly) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Gf128_powers
())) =
(va_QProc (va_code_Gf128_powers ()) ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem])
(va_wp_Gf128_powers h hkeys_b) (va_wpProof_Gf128_powers h hkeys_b))
//--
//-- Keyhash_init
[@ "opaque_to_smt" va_qattr]
let va_code_Keyhash_init alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0)
0) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10)
32) (va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons
(va_code_Gf128_powers ()) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_DestroyHeaplets
()) (va_CNil ()))))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Keyhash_init alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (va_codegen_success_Vspltisw
(va_op_vec_opr_vec 0) 0) (va_pbool_and (va_codegen_success_AESEncryptBlock alg) (va_pbool_and
(va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Gf128_powers ()) (va_pbool_and (va_codegen_success_DestroyHeaplets ())
(va_ttrue ())))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_mods: Vale.PPC64LE.QuickCode.va_mods_t ->
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
roundkeys_b: Vale.PPC64LE.Memory.buffer128 ->
hkeys_b: Vale.PPC64LE.Memory.buffer128
-> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit
(Vale.AES.PPC64LE.GF128_Init.va_code_Keyhash_init alg) | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCode.va_mods_t",
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat32",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.QuickCodes.qblock",
"Prims.unit",
"Prims.Cons",
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.InsMem.va_code_CreateHeaplets",
"Vale.PPC64LE.InsVector.va_code_Vspltisw",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.AES.PPC64LE.AES.va_code_AESEncryptBlock",
"Vale.PPC64LE.InsBasic.va_code_LoadImm64",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.PPC64LE.InsVector.va_code_Store128_byte16_buffer_index",
"Vale.PPC64LE.Decls.va_op_heaplet_mem_heaplet",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.AES.PPC64LE.GF128_Init.va_code_Gf128_powers",
"Vale.PPC64LE.Machine_s.Block",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Prims.Nil",
"Vale.PPC64LE.Machine_s.precode",
"Vale.PPC64LE.InsMem.va_code_DestroyHeaplets",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.va_QSeq",
"Vale.PPC64LE.QuickCodes.va_range1",
"Vale.PPC64LE.InsMem.va_quick_CreateHeaplets",
"Vale.Arch.HeapImpl.buffer_info",
"Vale.PPC64LE.InsMem.declare_buffer128",
"Vale.Arch.HeapImpl.Immutable",
"Vale.Arch.HeapImpl.Mutable",
"Vale.PPC64LE.QuickCodes.va_QBind",
"Vale.PPC64LE.InsVector.va_quick_Vspltisw",
"Vale.AES.PPC64LE.AES.va_quick_AESEncryptBlock",
"Vale.PPC64LE.Decls.va_get_vec",
"Vale.Arch.Types.reverse_bytes_quad32_seq",
"Vale.PPC64LE.Decls.buffer128_as_seq",
"Vale.PPC64LE.Decls.va_get_mem_heaplet",
"Vale.PPC64LE.InsBasic.va_quick_LoadImm64",
"Vale.PPC64LE.InsVector.va_quick_Store128_byte16_buffer_index",
"Vale.AES.PPC64LE.GF128_Init.va_quick_Gf128_powers",
"Vale.Math.Poly2.Bits_s.of_quad32",
"Vale.PPC64LE.QuickCodes.va_qAssertSquash",
"Vale.AES.AES_BE_s.is_aes_key_word",
"Prims.squash",
"Vale.PPC64LE.QuickCodes.va_qPURE",
"Prims.pure_post",
"Prims.l_and",
"Prims.l_True",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.l_iff",
"Vale.AES.OptPublic_BE.hkeys_reqs_pub",
"Vale.AES.GHash_BE.hkeys_reqs_priv",
"Vale.AES.GHash_BE.lemma_hkeys_reqs_pub_priv",
"Vale.PPC64LE.InsMem.va_quick_DestroyHeaplets",
"Vale.PPC64LE.QuickCodes.va_QEmpty",
"Vale.Def.Types_s.quad32",
"Vale.PPC64LE.Decls.s128",
"Vale.AES.AES_BE_s.aes_encrypt_word",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCode.va_quickCode",
"Vale.AES.PPC64LE.GF128_Init.va_code_Keyhash_init"
] | [] | false | false | false | false | false | let va_qcode_Keyhash_init
(va_mods: va_mods_t)
(alg: algorithm)
(key: (seq nat32))
(roundkeys_b hkeys_b: buffer128)
: (va_quickCode unit (va_code_Keyhash_init alg)) =
| (qblock va_mods
(fun (va_s: va_state) ->
let va_old_s:va_state = va_s in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 192 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_CreateHeaplets ([
declare_buffer128 roundkeys_b 0 Secret Immutable;
declare_buffer128 hkeys_b 1 Secret Mutable
]))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 196 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0)
(fun (va_s: va_state) _ ->
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 197 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_AESEncryptBlock alg
(va_get_vec 0 va_s)
key
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.buffer128_as_seq
(va_get_mem_heaplet 0 va_s)
roundkeys_b))
roundkeys_b)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 198 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 32)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 3)
(va_op_reg_opr_reg 10)
Secret
hkeys_b
2)
(fun (va_s: va_state) _ ->
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 201 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Gf128_powers (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec
0
va_s))
hkeys_b)
(fun (va_s: va_state) _ ->
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 203 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
((fun
(alg_10591: Vale.AES.AES_common_s.algorithm)
(key_10592:
(FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(input_10593: Vale.Def.Types_s.quad32)
->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592)
alg
key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0
))
(fun _ ->
let va_arg12:Vale.Def.Types_s.quad32 =
Vale.AES.AES_BE_s.aes_encrypt_word alg
key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32
0
0
0
0)
in
let va_arg11:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32
) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_s)
hkeys_b)
in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 203 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_: unit) ->
Vale.AES.GHash_BE.lemma_hkeys_reqs_pub_priv va_arg11
va_arg12)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_DestroyHeaplets ())
(va_QEmpty (())))))))))))) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_wpProof_ShiftKey1_128 | val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g)))) | val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g)))) | let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 160,
"start_col": 0,
"start_line": 153
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g)))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
f: Vale.Math.Poly2_s.poly ->
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.Math.Poly2_s.poly",
"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",
"Prims.Nil",
"Prims._assert",
"Vale.PPC64LE.Decls.va_state_eq",
"Vale.PPC64LE.Decls.va_update_vec",
"Vale.PPC64LE.Decls.va_update_ok",
"Vale.PPC64LE.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.PPC64LE.Machine_s.state",
"Vale.AES.PPC64LE.GF128_Init.va_lemma_ShiftKey1_128",
"Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_128"
] | [] | false | false | false | false | false | let va_wpProof_ShiftKey1_128 f va_s0 va_k =
| let va_sM, va_f0 = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM
(va_update_vec 3
va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_qcode_ShiftKey1_gf128_power | val va_qcode_ShiftKey1_gf128_power (va_mods: va_mods_t) (h: poly) (n: nat)
: (va_quickCode unit (va_code_ShiftKey1_gf128_power ())) | val va_qcode_ShiftKey1_gf128_power (va_mods: va_mods_t) (h: poly) (n: nat)
: (va_quickCode unit (va_code_ShiftKey1_gf128_power ())) | let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(())))))))))))))))))) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 239,
"start_col": 0,
"start_line": 198
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ()))))))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | va_mods: Vale.PPC64LE.QuickCode.va_mods_t -> h: Vale.Math.Poly2_s.poly -> n: Prims.nat
-> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit
(Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_gf128_power ()) | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCode.va_mods_t",
"Vale.Math.Poly2_s.poly",
"Prims.nat",
"Vale.PPC64LE.QuickCodes.qblock",
"Prims.unit",
"Prims.Cons",
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.InsVector.va_code_Vspltisw",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.PPC64LE.InsBasic.va_code_LoadImmShl64",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Prims.op_Minus",
"Vale.PPC64LE.InsVector.va_code_Mtvsrws",
"Vale.PPC64LE.InsVector.va_code_Vsldoi",
"Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_128",
"Prims.Nil",
"Vale.PPC64LE.Machine_s.precode",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.va_QSeq",
"Vale.PPC64LE.QuickCodes.va_range1",
"Vale.PPC64LE.InsVector.va_quick_Vspltisw",
"Vale.PPC64LE.QuickCodes.va_QBind",
"Vale.PPC64LE.InsBasic.va_quick_LoadImmShl64",
"Vale.PPC64LE.QuickCodes.va_qPURE",
"Prims.pure_post",
"Prims.l_and",
"Prims.l_True",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.eq2",
"Prims.int",
"Vale.Def.Types_s.ishl",
"Prims.op_Modulus",
"Prims.op_Multiply",
"Prims.pow2",
"Vale.AES.Types_helpers.lemma_ishl_64",
"Vale.PPC64LE.InsVector.va_quick_Mtvsrws",
"Vale.PPC64LE.InsVector.va_quick_Vsldoi",
"Vale.Math.Poly2.Bits_s.of_quad32",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Words_s.nat32",
"Vale.Math.Poly2_s.monomial",
"Vale.AES.GF128.lemma_gf128_high_bit",
"Vale.Math.Poly2_s.reverse",
"Vale.Math.Poly2_s.shift",
"Vale.Math.Poly2_s.add",
"Vale.AES.GF128_s.gf128_modulus_low_terms",
"Vale.AES.GF128.lemma_gf128_low_shift_1",
"Vale.AES.PPC64LE.GF128_Init.va_quick_ShiftKey1_128",
"Vale.AES.GHash_BE.gf128_power",
"Vale.AES.GF128.shift_key_1",
"Vale.AES.GHash_BE.g_power",
"Vale.AES.GHash_BE.lemma_gf128_power",
"Vale.PPC64LE.QuickCodes.va_QEmpty",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.Def.Words_s.nat64",
"Vale.PPC64LE.Machine_s.pow2_64",
"Vale.PPC64LE.Decls.va_get_vec",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCode.va_quickCode",
"Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_gf128_power"
] | [] | false | false | false | false | false | let va_qcode_ShiftKey1_gf128_power (va_mods: va_mods_t) (h: poly) (n: nat)
: (va_quickCode unit (va_code_ShiftKey1_gf128_power ())) =
| (qblock va_mods
(fun (va_s: va_state) ->
let va_old_s:va_state = va_s in
let hn:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (- 15872))
(fun (va_s: va_state) _ ->
let va_arg24:Vale.Def.Types_s.nat64 = (- 15872) `op_Modulus` pow2_64 in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_: unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (- 32768))
(fun (va_s: va_state) _ ->
let va_arg23:Vale.Def.Types_s.nat64 =
(- 32768) `op_Modulus` pow2_64
in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_: unit) ->
Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5)
(va_op_reg_opr_reg 10))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 1)
8)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1)
12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 2)
4)
(fun (va_s: va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_: unit) ->
Vale.AES.GF128.lemma_gf128_high_bit ()
)
(va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_: unit) ->
Vale.AES.GF128.lemma_gf128_low_shift_1
())
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms
)
(fun (va_s: va_state) _ ->
let va_arg22:Prims.nat =
n
in
let va_arg21:Vale.Math.Poly2_s.poly
=
h
in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_: unit) ->
Vale.AES.GHash_BE.lemma_gf128_power
va_arg21
va_arg22)
(va_QEmpty (()))))))))))))
)))))) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_qcode_Gf128_powers | val va_qcode_Gf128_powers (va_mods: va_mods_t) (h: poly) (hkeys_b: buffer128)
: (va_quickCode unit (va_code_Gf128_powers ())) | val va_qcode_Gf128_powers (va_mods: va_mods_t) (h: poly) (hkeys_b: buffer128)
: (va_quickCode unit (va_code_Gf128_powers ())) | let va_qcode_Gf128_powers (va_mods:va_mods_t) (h:poly) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gf128_powers ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 147 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 148 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 2) (fun (va_s:va_state) _ -> let
(va_arg18:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_1 va_arg18) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 150 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 151 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 152 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 153 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret hkeys_b 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 155 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 156 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 157 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Gf128MulRev128 ()) (fun (va_s:va_state) _ -> let (va_arg17:Vale.Math.Poly2_s.poly) =
h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 158 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_n va_arg17 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 159 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 160 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 161 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 162 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 1) (va_QEmpty (())))))))))))))))))) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 99,
"end_line": 387,
"start_col": 0,
"start_line": 350
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ())))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(()))))))))))))))))))
val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_gf128_power (h:poly) (n:nat) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in hn == Vale.AES.GHash_BE.g_power h n) /\ (forall (va_x_r10:nat64)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) . let
va_sM = va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_reg 10 va_x_r10 va_s0))))) in va_get_ok va_sM /\ (let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) ==>
va_k va_sM (())))
val va_wpProof_ShiftKey1_gf128_power : h:poly -> n:nat -> va_s0:va_state -> va_k:(va_state -> unit
-> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_gf128_power h n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_gf128_power h n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_gf128_power (va_code_ShiftKey1_gf128_power ()) va_s0 h n
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_gf128_power (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(va_QProc (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) (va_wp_ShiftKey1_gf128_power h n)
(va_wpProof_ShiftKey1_gf128_power h n))
//--
//-- Gf128_powers
val va_code_Gf128_powers : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gf128_powers () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vmr (va_op_vec_opr_vec
6) (va_op_vec_opr_vec 1)) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1))
(va_CCons (va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_Store128_byte16_buffer
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) Secret) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vmr
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Gf128MulRev128 ()) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_CCons
(va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16)
(va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CNil
())))))))))))))))
val va_codegen_success_Gf128_powers : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gf128_powers () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Gf128MulRev128 ()) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and (va_codegen_success_LoadImm64
(va_op_reg_opr_reg 10) 16) (va_pbool_and (va_codegen_success_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
10) Secret) (va_ttrue ())))))))))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_mods: Vale.PPC64LE.QuickCode.va_mods_t ->
h: Vale.Math.Poly2_s.poly ->
hkeys_b: Vale.PPC64LE.Memory.buffer128
-> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit
(Vale.AES.PPC64LE.GF128_Init.va_code_Gf128_powers ()) | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCode.va_mods_t",
"Vale.Math.Poly2_s.poly",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.QuickCodes.qblock",
"Prims.unit",
"Prims.Cons",
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.InsBasic.va_code_LoadImm64",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.PPC64LE.InsVector.va_code_Load128_byte16_buffer_index",
"Vale.PPC64LE.Decls.va_op_heaplet_mem_heaplet",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.PPC64LE.InsVector.va_code_Vmr",
"Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_gf128_power",
"Vale.PPC64LE.InsVector.va_code_Store128_byte16_buffer",
"Vale.AES.PPC64LE.GF128_Mul.va_code_Gf128MulRev128",
"Vale.PPC64LE.InsVector.va_code_Store128_byte16_buffer_index",
"Prims.Nil",
"Vale.PPC64LE.Machine_s.precode",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.va_QSeq",
"Vale.PPC64LE.QuickCodes.va_range1",
"Vale.PPC64LE.InsBasic.va_quick_LoadImm64",
"Vale.PPC64LE.QuickCodes.va_QBind",
"Vale.PPC64LE.InsVector.va_quick_Load128_byte16_buffer_index",
"Vale.PPC64LE.QuickCodes.va_qPURE",
"Prims.pure_post",
"Prims.l_and",
"Prims.l_True",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.eq2",
"Vale.AES.GHash_BE.g_power",
"Vale.AES.GHash_BE.lemma_g_power_1",
"Vale.PPC64LE.InsVector.va_quick_Vmr",
"Vale.AES.PPC64LE.GF128_Init.va_quick_ShiftKey1_gf128_power",
"Vale.PPC64LE.InsVector.va_quick_Store128_byte16_buffer",
"Vale.AES.PPC64LE.GF128_Mul.va_quick_Gf128MulRev128",
"Prims.op_Addition",
"Vale.AES.GF128.op_Star_Tilde",
"Vale.AES.GHash_BE.lemma_g_power_n",
"Vale.PPC64LE.InsVector.va_quick_Store128_byte16_buffer_index",
"Vale.PPC64LE.QuickCodes.va_QEmpty",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCode.va_quickCode",
"Vale.AES.PPC64LE.GF128_Init.va_code_Gf128_powers"
] | [] | false | false | false | false | false | let va_qcode_Gf128_powers (va_mods: va_mods_t) (h: poly) (hkeys_b: buffer128)
: (va_quickCode unit (va_code_Gf128_powers ())) =
| (qblock va_mods
(fun (va_s: va_state) ->
let va_old_s:va_state = va_s in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 147 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 32)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 148 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3)
(va_op_reg_opr_reg 10)
Secret
hkeys_b
2)
(fun (va_s: va_state) _ ->
let va_arg18:Vale.Math.Poly2_s.poly = h in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_: unit) -> Vale.AES.GHash_BE.lemma_g_power_1 va_arg18)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 150 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 151 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 152 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 1)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 153 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3)
Secret
hkeys_b
0)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 155 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 156 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 6))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 157 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Gf128MulRev128 ())
(fun (va_s: va_state) _ ->
let va_arg17:Vale.Math.Poly2_s.poly = h in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 158 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_: unit) ->
Vale.AES.GHash_BE.lemma_g_power_n va_arg17
1)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 159 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 1))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 160 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 2)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 161 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg
10)
16)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 162 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet
1)
(va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3)
(va_op_reg_opr_reg 10)
Secret
hkeys_b
1)
(va_QEmpty (()))))))))))))))))
)) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_lemma_ShiftKey1_128 | val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))))) | val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))))) | let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 129,
"start_col": 0,
"start_line": 114
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | va_b0: Vale.PPC64LE.Decls.va_code -> va_s0: Vale.PPC64LE.Decls.va_state -> f: Vale.Math.Poly2_s.poly
-> Prims.Ghost (Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.Decls.va_state",
"Vale.Math.Poly2_s.poly",
"Vale.PPC64LE.QuickCodes.fuel",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Vale.PPC64LE.Decls.va_fuel",
"Vale.PPC64LE.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.va_Mod_vec",
"Vale.PPC64LE.QuickCode.va_Mod_ok",
"Prims.Nil",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.list",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_128",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.tuple3",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCodes.va_wp_sound_code_norm",
"Prims.l_and",
"Vale.PPC64LE.QuickCodes.label",
"Vale.PPC64LE.QuickCodes.va_range1",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Vale.Math.Poly2.Bits_s.of_quad32",
"Vale.PPC64LE.Decls.va_get_vec",
"Vale.AES.GF128.shift_key_1",
"Vale.Math.Poly2_s.shift",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.AES.PPC64LE.GF128_Init.va_qcode_ShiftKey1_128"
] | [] | false | false | false | false | false | let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
| let va_mods:va_mods_t = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let va_sM, va_fM, va_g =
va_wp_sound_code_norm (va_code_ShiftKey1_128 ())
va_qc
va_s0
(fun va_s0 va_sM va_g ->
let () = va_g in
label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\
(let h:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
let h1:Vale.Math.Poly2_s.poly = Vale.Math.Poly2_s.shift h 1 in
let offset:Vale.Math.Poly2_s.poly =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0)
in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_wpProof_Keyhash_init | val va_wpProof_Keyhash_init : alg:algorithm -> key:(seq nat32) -> roundkeys_b:buffer128 ->
hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Keyhash_init alg key roundkeys_b hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Keyhash_init alg) ([va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | val va_wpProof_Keyhash_init : alg:algorithm -> key:(seq nat32) -> roundkeys_b:buffer128 ->
hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Keyhash_init alg key roundkeys_b hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Keyhash_init alg) ([va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | let va_wpProof_Keyhash_init alg key roundkeys_b hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Keyhash_init (va_code_Keyhash_init alg) va_s0 alg key roundkeys_b
hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))));
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1;
va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 586,
"start_col": 0,
"start_line": 574
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ())))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(()))))))))))))))))))
val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_gf128_power (h:poly) (n:nat) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in hn == Vale.AES.GHash_BE.g_power h n) /\ (forall (va_x_r10:nat64)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) . let
va_sM = va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_reg 10 va_x_r10 va_s0))))) in va_get_ok va_sM /\ (let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) ==>
va_k va_sM (())))
val va_wpProof_ShiftKey1_gf128_power : h:poly -> n:nat -> va_s0:va_state -> va_k:(va_state -> unit
-> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_gf128_power h n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_gf128_power h n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_gf128_power (va_code_ShiftKey1_gf128_power ()) va_s0 h n
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_gf128_power (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(va_QProc (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) (va_wp_ShiftKey1_gf128_power h n)
(va_wpProof_ShiftKey1_gf128_power h n))
//--
//-- Gf128_powers
val va_code_Gf128_powers : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gf128_powers () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vmr (va_op_vec_opr_vec
6) (va_op_vec_opr_vec 1)) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1))
(va_CCons (va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_Store128_byte16_buffer
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) Secret) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vmr
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Gf128MulRev128 ()) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_CCons
(va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16)
(va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CNil
())))))))))))))))
val va_codegen_success_Gf128_powers : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gf128_powers () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Gf128MulRev128 ()) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and (va_codegen_success_LoadImm64
(va_op_reg_opr_reg 10) 16) (va_pbool_and (va_codegen_success_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
10) Secret) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gf128_powers (va_mods:va_mods_t) (h:poly) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gf128_powers ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 147 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 148 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 2) (fun (va_s:va_state) _ -> let
(va_arg18:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_1 va_arg18) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 150 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 151 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 152 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 153 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret hkeys_b 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 155 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 156 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 157 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Gf128MulRev128 ()) (fun (va_s:va_state) _ -> let (va_arg17:Vale.Math.Poly2_s.poly) =
h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 158 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_n va_arg17 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 159 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 160 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 161 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 162 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 1) (va_QEmpty (()))))))))))))))))))
val va_lemma_Gf128_powers : va_b0:va_code -> va_s0:va_state -> h:poly -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gf128_powers ()) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) hkeys_b 3
(va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) /\ va_state_eq va_sM
(va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gf128_powers va_b0 va_s0 h hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gf128_powers va_mods h hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gf128_powers ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 128 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 141 column 61 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 142 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 143 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 1 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 2) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 145 column 84 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gf128_powers (h:poly) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg
3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap)
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32)
(va_x_v4:quad32) (va_x_v5:quad32) (va_x_v6:quad32) . let va_sM = va_upd_vec 6 va_x_v6
(va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem_heaplet 1
va_x_heap1 (va_upd_mem va_x_mem va_s0))))))))) in va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) ==> va_k va_sM (())))
val va_wpProof_Gf128_powers : h:poly -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state ->
unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gf128_powers h hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gf128_powers ()) ([va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gf128_powers h hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gf128_powers (va_code_Gf128_powers ()) va_s0 h hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gf128_powers (h:poly) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Gf128_powers
())) =
(va_QProc (va_code_Gf128_powers ()) ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem])
(va_wp_Gf128_powers h hkeys_b) (va_wpProof_Gf128_powers h hkeys_b))
//--
//-- Keyhash_init
[@ "opaque_to_smt" va_qattr]
let va_code_Keyhash_init alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0)
0) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10)
32) (va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons
(va_code_Gf128_powers ()) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_DestroyHeaplets
()) (va_CNil ()))))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Keyhash_init alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (va_codegen_success_Vspltisw
(va_op_vec_opr_vec 0) 0) (va_pbool_and (va_codegen_success_AESEncryptBlock alg) (va_pbool_and
(va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Gf128_powers ()) (va_pbool_and (va_codegen_success_DestroyHeaplets ())
(va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Keyhash_init (va_mods:va_mods_t) (alg:algorithm) (key:(seq nat32))
(roundkeys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Keyhash_init alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 192 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 roundkeys_b 0 Secret Immutable; declare_buffer128
hkeys_b 1 Secret Mutable])) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 196 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (fun (va_s:va_state) _ -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 197 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 0 va_s) key (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem_heaplet 0 va_s) roundkeys_b)) roundkeys_b)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 198 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 2) (fun (va_s:va_state) _ ->
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 201 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Gf128_powers (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 0 va_s)) hkeys_b) (fun
(va_s:va_state) _ -> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 203 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
((fun (alg_10591:Vale.AES.AES_common_s.algorithm) (key_10592:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10593:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592) alg key (Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0)) (fun _ -> let (va_arg12:Vale.Def.Types_s.quad32) =
Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0
0 0) in let (va_arg11:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
hkeys_b) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 203 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_hkeys_reqs_pub_priv va_arg11 va_arg12) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))))))))
[@"opaque_to_smt"]
let va_lemma_Keyhash_init va_b0 va_s0 alg key roundkeys_b hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok;
va_Mod_mem] in
let va_qc = va_qcode_Keyhash_init va_mods alg key roundkeys_b hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Keyhash_init alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 165 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 189 column 51 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 190 column 117 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b)) (Vale.AES.AES_BE_s.aes_encrypt_word alg
key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok;
va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
roundkeys_b: Vale.PPC64LE.Memory.buffer128 ->
hkeys_b: Vale.PPC64LE.Memory.buffer128 ->
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.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat32",
"Vale.PPC64LE.Memory.buffer128",
"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",
"Vale.PPC64LE.QuickCode.va_Mod_reg",
"Vale.PPC64LE.QuickCode.va_Mod_mem_layout",
"Vale.PPC64LE.QuickCode.va_Mod_mem_heaplet",
"Vale.PPC64LE.QuickCode.va_Mod_mem",
"Prims.Nil",
"Prims._assert",
"Vale.PPC64LE.Decls.va_state_eq",
"Vale.PPC64LE.Decls.va_update_vec",
"Vale.PPC64LE.Decls.va_update_reg",
"Vale.PPC64LE.Decls.va_update_mem_layout",
"Vale.PPC64LE.Decls.va_update_mem_heaplet",
"Vale.PPC64LE.Decls.va_update_ok",
"Vale.PPC64LE.Decls.va_update_mem",
"Vale.PPC64LE.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.PPC64LE.Machine_s.state",
"Vale.AES.PPC64LE.GF128_Init.va_lemma_Keyhash_init",
"Vale.AES.PPC64LE.GF128_Init.va_code_Keyhash_init"
] | [] | false | false | false | false | false | let va_wpProof_Keyhash_init alg key roundkeys_b hkeys_b va_s0 va_k =
| let va_sM, va_f0 =
va_lemma_Keyhash_init (va_code_Keyhash_init alg) va_s0 alg key roundkeys_b hkeys_b
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM
(va_update_vec 6
va_sM
(va_update_vec 5
va_sM
(va_update_vec 4
va_sM
(va_update_vec 3
va_sM
(va_update_vec 2
va_sM
(va_update_vec 1
va_sM
(va_update_vec 0
va_sM
(va_update_reg 10
va_sM
(va_update_mem_layout va_sM
(va_update_mem_heaplet 1
va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))
)))));
va_lemma_norm_mods ([
va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem
])
va_sM
va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_lemma_ShiftKey1_gf128_power | val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))))) | val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))))) | let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 269,
"start_col": 0,
"start_line": 254
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ())))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(()))))))))))))))))))
val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_b0: Vale.PPC64LE.Decls.va_code ->
va_s0: Vale.PPC64LE.Decls.va_state ->
h: Vale.Math.Poly2_s.poly ->
n: Prims.nat
-> Prims.Ghost (Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.Decls.va_state",
"Vale.Math.Poly2_s.poly",
"Prims.nat",
"Vale.PPC64LE.QuickCodes.fuel",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Vale.PPC64LE.Decls.va_fuel",
"Vale.PPC64LE.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.va_Mod_vec",
"Vale.PPC64LE.QuickCode.va_Mod_reg",
"Vale.PPC64LE.QuickCode.va_Mod_ok",
"Prims.Nil",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.list",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.AES.PPC64LE.GF128_Init.va_code_ShiftKey1_gf128_power",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.tuple3",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCodes.va_wp_sound_code_norm",
"Prims.l_and",
"Vale.PPC64LE.QuickCodes.label",
"Vale.PPC64LE.QuickCodes.va_range1",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Vale.Math.Poly2.Bits_s.of_quad32",
"Vale.PPC64LE.Decls.va_get_vec",
"Vale.AES.GHash_BE.gf128_power",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.AES.PPC64LE.GF128_Init.va_qcode_ShiftKey1_gf128_power"
] | [] | false | false | false | false | false | let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
| let va_mods:va_mods_t =
[va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10; va_Mod_ok]
in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let va_sM, va_fM, va_g =
va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ())
va_qc
va_s0
(fun va_s0 va_sM va_g ->
let () = va_g in
label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\
(let hn:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([
va_Mod_vec 5;
va_Mod_vec 4;
va_Mod_vec 3;
va_Mod_vec 2;
va_Mod_vec 1;
va_Mod_reg 10;
va_Mod_ok
])
va_sM
va_s0;
(va_sM, va_fM) | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_lemma_Gf128_powers | val va_lemma_Gf128_powers : va_b0:va_code -> va_s0:va_state -> h:poly -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gf128_powers ()) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) hkeys_b 3
(va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) /\ va_state_eq va_sM
(va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))) | val va_lemma_Gf128_powers : va_b0:va_code -> va_s0:va_state -> h:poly -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gf128_powers ()) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) hkeys_b 3
(va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) /\ va_state_eq va_sM
(va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))) | let va_lemma_Gf128_powers va_b0 va_s0 h hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gf128_powers va_mods h hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gf128_powers ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 128 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 141 column 61 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 142 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 143 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 1 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 2) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 145 column 84 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM
va_s0;
(va_sM, va_fM) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 437,
"start_col": 0,
"start_line": 411
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ())))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(()))))))))))))))))))
val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_gf128_power (h:poly) (n:nat) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in hn == Vale.AES.GHash_BE.g_power h n) /\ (forall (va_x_r10:nat64)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) . let
va_sM = va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_reg 10 va_x_r10 va_s0))))) in va_get_ok va_sM /\ (let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) ==>
va_k va_sM (())))
val va_wpProof_ShiftKey1_gf128_power : h:poly -> n:nat -> va_s0:va_state -> va_k:(va_state -> unit
-> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_gf128_power h n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_gf128_power h n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_gf128_power (va_code_ShiftKey1_gf128_power ()) va_s0 h n
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_gf128_power (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(va_QProc (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) (va_wp_ShiftKey1_gf128_power h n)
(va_wpProof_ShiftKey1_gf128_power h n))
//--
//-- Gf128_powers
val va_code_Gf128_powers : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gf128_powers () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vmr (va_op_vec_opr_vec
6) (va_op_vec_opr_vec 1)) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1))
(va_CCons (va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_Store128_byte16_buffer
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) Secret) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vmr
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Gf128MulRev128 ()) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_CCons
(va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16)
(va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CNil
())))))))))))))))
val va_codegen_success_Gf128_powers : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gf128_powers () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Gf128MulRev128 ()) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and (va_codegen_success_LoadImm64
(va_op_reg_opr_reg 10) 16) (va_pbool_and (va_codegen_success_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
10) Secret) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gf128_powers (va_mods:va_mods_t) (h:poly) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gf128_powers ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 147 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 148 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 2) (fun (va_s:va_state) _ -> let
(va_arg18:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_1 va_arg18) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 150 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 151 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 152 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 153 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret hkeys_b 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 155 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 156 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 157 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Gf128MulRev128 ()) (fun (va_s:va_state) _ -> let (va_arg17:Vale.Math.Poly2_s.poly) =
h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 158 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_n va_arg17 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 159 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 160 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 161 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 162 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 1) (va_QEmpty (()))))))))))))))))))
val va_lemma_Gf128_powers : va_b0:va_code -> va_s0:va_state -> h:poly -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gf128_powers ()) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) hkeys_b 3
(va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) /\ va_state_eq va_sM
(va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_b0: Vale.PPC64LE.Decls.va_code ->
va_s0: Vale.PPC64LE.Decls.va_state ->
h: Vale.Math.Poly2_s.poly ->
hkeys_b: Vale.PPC64LE.Memory.buffer128
-> Prims.Ghost (Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.Decls.va_state",
"Vale.Math.Poly2_s.poly",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.QuickCodes.fuel",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Vale.PPC64LE.Decls.va_fuel",
"Vale.PPC64LE.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.va_Mod_vec",
"Vale.PPC64LE.QuickCode.va_Mod_reg",
"Vale.PPC64LE.QuickCode.va_Mod_mem_heaplet",
"Vale.PPC64LE.QuickCode.va_Mod_ok",
"Vale.PPC64LE.QuickCode.va_Mod_mem",
"Prims.Nil",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.list",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.AES.PPC64LE.GF128_Init.va_code_Gf128_powers",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.tuple3",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCodes.va_wp_sound_code_norm",
"Prims.l_and",
"Vale.PPC64LE.QuickCodes.label",
"Vale.PPC64LE.QuickCodes.va_range1",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Vale.PPC64LE.Decls.modifies_mem",
"Vale.PPC64LE.Decls.loc_buffer",
"Vale.PPC64LE.Memory.vuint128",
"Vale.PPC64LE.Decls.va_get_mem_heaplet",
"Vale.Math.Poly2.Bits_s.of_quad32",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.PPC64LE.Decls.buffer128_read",
"Vale.AES.GHash_BE.gf128_power",
"Vale.PPC64LE.Machine_s.quad32",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.AES.PPC64LE.GF128_Init.va_qcode_Gf128_powers"
] | [] | false | false | false | false | false | let va_lemma_Gf128_powers va_b0 va_s0 h hkeys_b =
| let va_mods:va_mods_t =
[
va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem
]
in
let va_qc = va_qcode_Gf128_powers va_mods h hkeys_b in
let va_sM, va_fM, va_g =
va_wp_sound_code_norm (va_code_Gf128_powers ())
va_qc
va_s0
(fun va_s0 va_sM va_g ->
let () = va_g in
label va_range1
"***** POSTCONDITION NOT MET AT line 128 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 141 column 61 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b)
(va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM)) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 142 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read
hkeys_b
0
(va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 143 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read
hkeys_b
1
(va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 2) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 145 column 84 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([
va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem
])
va_sM
va_s0;
(va_sM, va_fM) | false |
Steel.ST.C.Types.UserStruct.fsti | Steel.ST.C.Types.UserStruct.unstruct_field_alt | val unstruct_field_alt
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(#v: Ghost.erased t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(#v': Ghost.erased (sd.field_desc.fd_type field))
(r': ref (sd.field_desc.fd_typedef field))
: STGhost (Ghost.erased t)
opened
(((has_struct_field r field r') `star` (pts_to r v)) `star` (pts_to r' v'))
(fun s' -> (has_struct_field r field r') `star` (pts_to r s'))
(sd.get v field == unknown (sd.field_desc.fd_typedef field))
(fun s' -> Ghost.reveal s' == set sd v field v') | val unstruct_field_alt
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(#v: Ghost.erased t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(#v': Ghost.erased (sd.field_desc.fd_type field))
(r': ref (sd.field_desc.fd_typedef field))
: STGhost (Ghost.erased t)
opened
(((has_struct_field r field r') `star` (pts_to r v)) `star` (pts_to r' v'))
(fun s' -> (has_struct_field r field r') `star` (pts_to r s'))
(sd.get v field == unknown (sd.field_desc.fd_typedef field))
(fun s' -> Ghost.reveal s' == set sd v field v') | let unstruct_field_alt
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(#v: Ghost.erased t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(#v': Ghost.erased (sd.field_desc.fd_type field))
(r': ref (sd.field_desc.fd_typedef field))
: STGhost (Ghost.erased t) opened
(has_struct_field r field r' `star` pts_to r v `star` pts_to r' v')
(fun s' -> has_struct_field r field r' `star` pts_to r s')
(
sd.get v field == unknown (sd.field_desc.fd_typedef field)
)
(fun s' -> Ghost.reveal s' == set sd v field v')
= unstruct_field r field r';
_ | {
"file_name": "lib/steel/c/Steel.ST.C.Types.UserStruct.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 3,
"end_line": 216,
"start_col": 0,
"start_line": 199
} | module Steel.ST.C.Types.UserStruct
open Steel.ST.Util
open Steel.ST.C.Types.Struct.Aux
module Set = FStar.Set
(* This library allows the user to define their own struct type, with
a constructor from field values, and a destructor to field values for
each field. This may be necessary for recursive structs *)
let set_def
(#t: eqtype)
(s: FStar.Set.set t)
(x: t)
: Tot bool
= FStar.Set.mem x s
noextract
let nonempty_set (t: eqtype) =
(s: Set.set t { exists x . set_def s x == true })
noextract
let set_snoc // for associativity reasons
(#t: eqtype) (q: FStar.Set.set t) (a: t) : Pure (nonempty_set t)
(requires True)
(ensures (fun s ->
(forall (x: t). {:pattern FStar.Set.mem x s} FStar.Set.mem x s == (x = a || FStar.Set.mem x q))
))
= q `FStar.Set.union` FStar.Set.singleton a
[@@noextract_to "krml"]
let field_t (s: Set.set string) : Tot eqtype =
(f: string { Set.mem f s })
[@@noextract_to "krml"; norm_field_attr]
inline_for_extraction // for field_desc.fd_type
noeq
type struct_def (t: Type) = {
fields: Set.set string;
field_desc: field_description_gen_t (field_t fields);
mk: ((f: field_t fields) -> Tot (field_desc.fd_type f)) -> Tot t;
get: (t -> (f: field_t fields) -> Tot (field_desc.fd_type f));
get_mk: (phi: ((f: field_t fields) -> Tot (field_desc.fd_type f))) -> (f: field_t fields) -> Lemma
(get (mk phi) f == phi f);
extensionality: (x1: t) -> (x2: t) -> ((f: field_t fields) -> Lemma (get x1 f == get x2 f)) -> Lemma (x1 == x2);
}
let nonempty_set_nonempty_type (x: string) (s: Set.set string) : Lemma
(requires (x `Set.mem` s))
(ensures (exists (x: field_t s) . True))
= Classical.exists_intro (fun (_: field_t s) -> True) x
[@@noextract_to "krml"]
let set_aux
(#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f': field_t sd.fields)
: Tot (sd.field_desc.fd_type f')
= if f = f' then v else sd.get x f'
[@@noextract_to "krml"]
let set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) : Tot t =
sd.mk (set_aux sd x f v)
let get_set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f' : field_t sd.fields) : Lemma
(sd.get (set sd x f v) f' == (if f = f' then v else sd.get x f'))
[SMTPat (sd.get (set sd x f v) f')]
= sd.get_mk (set_aux sd x f v) f'
[@@noextract_to "krml"]
val struct_typedef
(#t: Type)
(sd: struct_def t)
: Tot (typedef t)
val has_struct_field
(#t: Type)
(#sd: struct_def t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(r': ref (sd.field_desc.fd_typedef field))
: Tot vprop
val has_struct_field_dup
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(r': ref (sd.field_desc.fd_typedef field))
: STGhostT unit opened
(has_struct_field r field r')
(fun _ -> has_struct_field r field r' `star` has_struct_field r field r')
val has_struct_field_inj
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(r1 r2: ref (sd.field_desc.fd_typedef field))
: STGhostT unit opened
(has_struct_field r field r1 `star` has_struct_field r field r2)
(fun _ -> has_struct_field r field r1 `star` has_struct_field r field r2 `star` ref_equiv r1 r2)
val has_struct_field_equiv_from
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(r1: ref (struct_typedef sd))
(field: field_t sd.fields)
(r': ref (sd.field_desc.fd_typedef field))
(r2: ref (struct_typedef sd))
: STGhostT unit opened
(ref_equiv r1 r2 `star` has_struct_field r1 field r')
(fun _ -> ref_equiv r1 r2 `star` has_struct_field r2 field r')
val has_struct_field_equiv_to
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(r1' r2': ref (sd.field_desc.fd_typedef field))
: STGhostT unit opened
(ref_equiv r1' r2' `star` has_struct_field r field r1')
(fun _ -> ref_equiv r1' r2' `star` has_struct_field r field r2')
val ghost_struct_field_focus
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(#v: Ghost.erased t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(r': ref (sd.field_desc.fd_typedef field))
: STGhostT unit opened
(has_struct_field r field r' `star` pts_to r v)
(fun _ -> has_struct_field r field r' `star` pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field))) `star` pts_to r' (sd.get v field))
val ghost_struct_field
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(#v: Ghost.erased t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
: STGhostT (Ghost.erased (ref (sd.field_desc.fd_typedef field))) opened
(pts_to r v)
(fun r' -> has_struct_field r field r' `star` pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field))) `star` pts_to r' (sd.get v field))
[@@noextract_to "krml"] // primitive
val struct_field0
(#t: Type)
(t': Type0)
(#sd: struct_def t)
(#v: Ghost.erased t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(td': typedef t' {
t' == sd.field_desc.fd_type field /\
td' == sd.field_desc.fd_typedef field
})
: STT (ref td')
(pts_to r v)
(fun r' -> has_struct_field r field (coerce_eq () r') `star` pts_to r (set sd (Ghost.reveal v) field (unknown (sd.field_desc.fd_typedef field))) `star` pts_to #_ #(sd.field_desc.fd_typedef field) (coerce_eq () r') (sd.get (Ghost.reveal v) field))
inline_for_extraction [@@noextract_to "krml"] // primitive
let struct_field
(#t: Type)
(#sd: struct_def t)
(#v: Ghost.erased t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
: STT (ref #(norm norm_field_steps (sd.field_desc.fd_type field)) (sd.field_desc.fd_typedef field))
(pts_to r v)
(fun r' -> pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field))) `star` pts_to #(norm norm_field_steps (sd.field_desc.fd_type field)) r' (sd.get v field) `star` has_struct_field r field r')
= struct_field0
(norm norm_field_steps (sd.field_desc.fd_type field))
r
field
(sd.field_desc.fd_typedef field)
val unstruct_field
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(#v: Ghost.erased t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(#v': Ghost.erased (sd.field_desc.fd_type field))
(r': ref (sd.field_desc.fd_typedef field))
: STGhost unit opened
(has_struct_field r field r' `star` pts_to r v `star` pts_to r' v')
(fun _ -> has_struct_field r field r' `star` pts_to r (set sd v field v'))
(
sd.get v field == unknown (sd.field_desc.fd_typedef field)
)
(fun _ -> True) | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.C.Types.Struct.Aux.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.C.Types.UserStruct.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "Set"
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.Struct.Aux",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
r: Steel.ST.C.Types.Base.ref (Steel.ST.C.Types.UserStruct.struct_typedef sd) ->
field: Steel.ST.C.Types.UserStruct.field_t (Mkstruct_def?.fields sd) ->
r':
Steel.ST.C.Types.Base.ref (Mkfield_description_gen_t?.fd_typedef (Mkstruct_def?.field_desc sd)
field)
-> Steel.ST.Effect.Ghost.STGhost (FStar.Ghost.erased t) | Steel.ST.Effect.Ghost.STGhost | [] | [] | [
"Steel.Memory.inames",
"Steel.ST.C.Types.UserStruct.struct_def",
"FStar.Ghost.erased",
"Steel.ST.C.Types.Base.ref",
"Steel.ST.C.Types.UserStruct.struct_typedef",
"Steel.ST.C.Types.UserStruct.field_t",
"Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__fields",
"Steel.ST.C.Types.Struct.Aux.__proj__Mkfield_description_gen_t__item__fd_type",
"Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__field_desc",
"Steel.ST.C.Types.Struct.Aux.__proj__Mkfield_description_gen_t__item__fd_typedef",
"FStar.Ghost.hide",
"Steel.ST.C.Types.UserStruct.set",
"FStar.Ghost.reveal",
"Prims.unit",
"Steel.ST.C.Types.UserStruct.unstruct_field",
"Steel.Effect.Common.star",
"Steel.ST.C.Types.UserStruct.has_struct_field",
"Steel.ST.C.Types.Base.pts_to",
"Steel.Effect.Common.vprop",
"Prims.eq2",
"Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__get",
"Steel.ST.C.Types.Base.unknown",
"Prims.l_True"
] | [] | false | true | false | false | false | let unstruct_field_alt
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(#v: Ghost.erased t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(#v': Ghost.erased (sd.field_desc.fd_type field))
(r': ref (sd.field_desc.fd_typedef field))
: STGhost (Ghost.erased t)
opened
(((has_struct_field r field r') `star` (pts_to r v)) `star` (pts_to r' v'))
(fun s' -> (has_struct_field r field r') `star` (pts_to r s'))
(sd.get v field == unknown (sd.field_desc.fd_typedef field))
(fun s' -> Ghost.reveal s' == set sd v field v') =
| unstruct_field r field r';
_ | false |
Steel.GhostMonotonicHigherReference.fst | Steel.GhostMonotonicHigherReference.alloc | val alloc (#opened: _) (#a:Type) (p:Preorder.preorder a) (v:a)
: SteelGhostT (ref a p) opened emp (fun r -> pts_to r full_perm v) | val alloc (#opened: _) (#a:Type) (p:Preorder.preorder a) (v:a)
: SteelGhostT (ref a p) opened emp (fun r -> pts_to r full_perm v) | let alloc #_ (#a:Type) (p:Preorder.preorder a) (v:a)
= let h = Current [v] full_perm in
assert (compatible pcm_history h h);
let x : ref a p = alloc h in
intro_pure_full x v h;
x | {
"file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 5,
"end_line": 73,
"start_col": 0,
"start_line": 68
} | (*
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.GhostMonotonicHigherReference
open FStar.Ghost
open FStar.PCM
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.GhostPCMReference
open Steel.FractionalPermission
open Steel.Preorder
module Preorder = FStar.Preorder
module Q = Steel.Preorder
module M = Steel.Memory
module PR = Steel.GhostPCMReference
module A = Steel.Effect.Atomic
open FStar.Real
#set-options "--ide_id_info_off"
let ref a p = PR.ref (history a p) pcm_history
[@@__reduce__]
let pts_to_body #a #p (r:ref a p) (f:perm) (v:a) (h:history a p) =
PR.pts_to r h `star`
pure (history_val h v f)
let pts_to' (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v: a) =
h_exists (pts_to_body r f v)
let pts_to_sl r f v = hp_of (pts_to' r f v)
let intro_pure #opened #a #p #f
(r:ref a p)
(v:a)
(h:history a p { history_val h v f })
: SteelGhostT unit opened
(PR.pts_to r h)
(fun _ -> pts_to_body r f v h)
= A.intro_pure (history_val h v f)
let intro_pure_full #opened #a #p #f
(r:ref a p)
(v:a)
(h:history a p { history_val h v f })
: SteelGhostT unit opened
(PR.pts_to r h)
(fun _ -> pts_to r f v)
= intro_pure #_ #a #p #f r v h;
intro_exists h (pts_to_body r f v) | {
"checked_file": "/",
"dependencies": [
"Steel.Preorder.fst.checked",
"Steel.Memory.fsti.checked",
"Steel.GhostPCMReference.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.GhostMonotonicHigherReference.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Real",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Effect.Atomic",
"short_module": "A"
},
{
"abbrev": true,
"full_module": "Steel.GhostPCMReference",
"short_module": "PR"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Steel.Preorder",
"short_module": "Q"
},
{
"abbrev": false,
"full_module": "Steel.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.GhostPCMReference",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"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": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: FStar.Preorder.preorder a -> v: a
-> Steel.Effect.Atomic.SteelGhostT (Steel.GhostMonotonicHigherReference.ref a p) | Steel.Effect.Atomic.SteelGhostT | [] | [] | [
"Steel.Memory.inames",
"FStar.Preorder.preorder",
"Steel.GhostMonotonicHigherReference.ref",
"Prims.unit",
"Steel.GhostMonotonicHigherReference.intro_pure_full",
"Steel.FractionalPermission.full_perm",
"Steel.GhostPCMReference.alloc",
"Steel.Preorder.history",
"Steel.Preorder.pcm_history",
"Steel.GhostPCMReference.ref",
"Prims._assert",
"FStar.PCM.compatible",
"Steel.Preorder.Current",
"Prims.Cons",
"Prims.Nil"
] | [] | false | true | false | false | false | let alloc #_ (#a: Type) (p: Preorder.preorder a) (v: a) =
| let h = Current [v] full_perm in
assert (compatible pcm_history h h);
let x:ref a p = alloc h in
intro_pure_full x v h;
x | false |
Vale.AES.PPC64LE.GF128_Init.fst | Vale.AES.PPC64LE.GF128_Init.va_lemma_Keyhash_init | val va_lemma_Keyhash_init : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> key:(seq nat32) ->
roundkeys_b:buffer128 -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Keyhash_init alg) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg =
AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\
Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) ==
Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128
(va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1)
(va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0)
(va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM) /\
Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b)) (Vale.AES.AES_BE_s.aes_encrypt_word alg
key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) /\ va_state_eq va_sM
(va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0)))))))))))))) | val va_lemma_Keyhash_init : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> key:(seq nat32) ->
roundkeys_b:buffer128 -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Keyhash_init alg) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg =
AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\
Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) ==
Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128
(va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1)
(va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0)
(va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM) /\
Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b)) (Vale.AES.AES_BE_s.aes_encrypt_word alg
key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) /\ va_state_eq va_sM
(va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0)))))))))))))) | let va_lemma_Keyhash_init va_b0 va_s0 alg key roundkeys_b hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok;
va_Mod_mem] in
let va_qc = va_qcode_Keyhash_init va_mods alg key roundkeys_b hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Keyhash_init alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 165 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 189 column 51 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 190 column 117 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b)) (Vale.AES.AES_BE_s.aes_encrypt_word alg
key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok;
va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM) | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 570,
"start_col": 0,
"start_line": 550
} | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- ShiftKey1_128
val va_code_ShiftKey1_128 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_128 () =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_CCons
(va_code_ShiftLeft128_1 ()) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vcmpequw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) 0) (va_CCons (va_code_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec
3) (va_op_vec_opr_vec 4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 3)) (va_CNil ())))))))))
val va_codegen_success_ShiftKey1_128 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_128 () =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_ShiftLeft128_1 ()) (va_pbool_and (va_codegen_success_VPolyAnd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0)
(va_pbool_and (va_codegen_success_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_128 (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 80 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftLeft128_1 h) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 81 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask h1) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_define_i h 1 128) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 84 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 85 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vcmpequw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_test_high_bit h) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 87 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) 0) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 88 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_zero ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 89 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_ones ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 92 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAnd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 93 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_and_consts ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 94 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3))
(va_QEmpty (()))))))))))))))))
val va_lemma_ShiftKey1_128 : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_128 ()) va_s0 /\ va_get_ok va_s0 /\ (let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) /\
va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_128 va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_128 va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_128 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_128 (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift h 1 in let
(offset:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2_s.monomial 127 /\
offset == Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift (Vale.Math.Poly2_s.add
(Vale.Math.Poly2_s.monomial 128) f) (-1)) 127) /\ (forall (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) . let va_sM = va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1
va_s0)) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let (h1:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.shift h 1 in let (offset:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 1 va_sM) == Vale.AES.GF128.shift_key_1 128 f h) ==> va_k va_sM (())))
val va_wpProof_ShiftKey1_128 : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_128 f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_128 f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_128 (va_code_ShiftKey1_128 ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_128 (f:poly) : (va_quickCode unit (va_code_ShiftKey1_128 ())) =
(va_QProc (va_code_ShiftKey1_128 ()) ([va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1])
(va_wp_ShiftKey1_128 f) (va_wpProof_ShiftKey1_128 f))
//--
//-- ShiftKey1_gf128_power
val va_code_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_ShiftKey1_gf128_power () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 1) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 2) 1) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_CCons (va_code_ShiftKey1_128 ()) (va_CNil
()))))))))))))
val va_codegen_success_ShiftKey1_gf128_power : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ShiftKey1_gf128_power () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 1) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 2) 1) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (va_pbool_and (va_codegen_success_ShiftKey1_128
()) (va_ttrue ())))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ShiftKey1_gf128_power (va_mods:va_mods_t) (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 110 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 1) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 111 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 2) 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 112 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg24:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 113 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg24 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 115 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-32768)) (fun (va_s:va_state) _ -> let
(va_arg23:Vale.Def.Types_s.nat64) = (-32768) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 116 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg23 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 117 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 5) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 118 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 1) 8) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 119 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 1) 12)
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 120 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 2) 4) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 121 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_high_bit ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 122 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_low_shift_1 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 124 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_128 gf128_modulus_low_terms) (fun (va_s:va_state) _ -> let
(va_arg22:Prims.nat) = n in let (va_arg21:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 125 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg21 va_arg22) (va_QEmpty
(()))))))))))))))))))
val va_lemma_ShiftKey1_gf128_power : va_b0:va_code -> va_s0:va_state -> h:poly -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_ShiftKey1_gf128_power ()) va_s0 /\ va_get_ok va_s0 /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in hn
== Vale.AES.GHash_BE.g_power h n)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) /\
va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))
[@"opaque_to_smt"]
let va_lemma_ShiftKey1_gf128_power va_b0 va_s0 h n =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_ShiftKey1_gf128_power va_mods h n in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ShiftKey1_gf128_power ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 108 column 43 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_ShiftKey1_gf128_power (h:poly) (n:nat) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 3 va_s0) in hn == Vale.AES.GHash_BE.g_power h n) /\ (forall (va_x_r10:nat64)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) . let
va_sM = va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_reg 10 va_x_r10 va_s0))))) in va_get_ok va_sM /\ (let
(hn:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.AES.GHash_BE.gf128_power h n) ==>
va_k va_sM (())))
val va_wpProof_ShiftKey1_gf128_power : h:poly -> n:nat -> va_s0:va_state -> va_k:(va_state -> unit
-> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_ShiftKey1_gf128_power h n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_ShiftKey1_gf128_power h n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ShiftKey1_gf128_power (va_code_ShiftKey1_gf128_power ()) va_s0 h n
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_ShiftKey1_gf128_power (h:poly) (n:nat) : (va_quickCode unit
(va_code_ShiftKey1_gf128_power ())) =
(va_QProc (va_code_ShiftKey1_gf128_power ()) ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_reg 10]) (va_wp_ShiftKey1_gf128_power h n)
(va_wpProof_ShiftKey1_gf128_power h n))
//--
//-- Gf128_powers
val va_code_Gf128_powers : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gf128_powers () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vmr (va_op_vec_opr_vec
6) (va_op_vec_opr_vec 1)) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1))
(va_CCons (va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_Store128_byte16_buffer
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) Secret) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vmr
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Gf128MulRev128 ()) (va_CCons
(va_code_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_CCons
(va_code_ShiftKey1_gf128_power ()) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16)
(va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CNil
())))))))))))))))
val va_codegen_success_Gf128_powers : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gf128_powers () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Gf128MulRev128 ()) (va_pbool_and
(va_codegen_success_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_pbool_and
(va_codegen_success_ShiftKey1_gf128_power ()) (va_pbool_and (va_codegen_success_LoadImm64
(va_op_reg_opr_reg 10) 16) (va_pbool_and (va_codegen_success_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
10) Secret) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gf128_powers (va_mods:va_mods_t) (h:poly) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gf128_powers ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 147 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 148 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 2) (fun (va_s:va_state) _ -> let
(va_arg18:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_1 va_arg18) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 150 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 151 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 152 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 153 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret hkeys_b 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 155 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 156 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 157 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Gf128MulRev128 ()) (fun (va_s:va_state) _ -> let (va_arg17:Vale.Math.Poly2_s.poly) =
h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 158 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_g_power_n va_arg17 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 159 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 160 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_ShiftKey1_gf128_power h 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 161 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 162 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 1) (va_QEmpty (()))))))))))))))))))
val va_lemma_Gf128_powers : va_b0:va_code -> va_s0:va_state -> h:poly -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gf128_powers ()) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) hkeys_b 3
(va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) /\ va_state_eq va_sM
(va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gf128_powers va_b0 va_s0 h hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gf128_powers va_mods h hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gf128_powers ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 128 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 141 column 61 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 142 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 143 column 96 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 1 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 2) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 145 column 84 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gf128_powers (h:poly) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg
3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 1 va_s0))) == h /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap)
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32)
(va_x_v4:quad32) (va_x_v5:quad32) (va_x_v6:quad32) . let va_sM = va_upd_vec 6 va_x_v6
(va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem_heaplet 1
va_x_heap1 (va_upd_mem va_x_mem va_s0))))))))) in va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_mem (Vale.PPC64LE.Decls.loc_buffer #Vale.PPC64LE.Memory.vuint128
hkeys_b) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read hkeys_b 0 (va_get_mem_heaplet 1 va_sM))) ==
Vale.AES.GHash_BE.gf128_power h 1 /\ Vale.Math.Poly2.Bits_s.of_quad32
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read hkeys_b 1
(va_get_mem_heaplet 1 va_sM))) == Vale.AES.GHash_BE.gf128_power h 2 /\
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_sM) ==
Vale.PPC64LE.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 1 va_s0) ==> va_k va_sM (())))
val va_wpProof_Gf128_powers : h:poly -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state ->
unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gf128_powers h hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gf128_powers ()) ([va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gf128_powers h hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gf128_powers (va_code_Gf128_powers ()) va_s0 h hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gf128_powers (h:poly) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Gf128_powers
())) =
(va_QProc (va_code_Gf128_powers ()) ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem])
(va_wp_Gf128_powers h hkeys_b) (va_wpProof_Gf128_powers h hkeys_b))
//--
//-- Keyhash_init
[@ "opaque_to_smt" va_qattr]
let va_code_Keyhash_init alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0)
0) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10)
32) (va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CCons
(va_code_Gf128_powers ()) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_DestroyHeaplets
()) (va_CNil ()))))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Keyhash_init alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (va_codegen_success_Vspltisw
(va_op_vec_opr_vec 0) 0) (va_pbool_and (va_codegen_success_AESEncryptBlock alg) (va_pbool_and
(va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Gf128_powers ()) (va_pbool_and (va_codegen_success_DestroyHeaplets ())
(va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Keyhash_init (va_mods:va_mods_t) (alg:algorithm) (key:(seq nat32))
(roundkeys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Keyhash_init alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 192 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 roundkeys_b 0 Secret Immutable; declare_buffer128
hkeys_b 1 Secret Mutable])) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 196 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (fun (va_s:va_state) _ -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 197 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 0 va_s) key (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem_heaplet 0 va_s) roundkeys_b)) roundkeys_b)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 198 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 32) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret hkeys_b 2) (fun (va_s:va_state) _ ->
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 201 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_Gf128_powers (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 0 va_s)) hkeys_b) (fun
(va_s:va_state) _ -> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 203 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
((fun (alg_10591:Vale.AES.AES_common_s.algorithm) (key_10592:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10593:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592) alg key (Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0)) (fun _ -> let (va_arg12:Vale.Def.Types_s.quad32) =
Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0
0 0) in let (va_arg11:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
hkeys_b) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 203 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_hkeys_reqs_pub_priv va_arg11 va_arg12) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (())))))))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"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.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_b0: Vale.PPC64LE.Decls.va_code ->
va_s0: Vale.PPC64LE.Decls.va_state ->
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
roundkeys_b: Vale.PPC64LE.Memory.buffer128 ->
hkeys_b: Vale.PPC64LE.Memory.buffer128
-> Prims.Ghost (Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.Decls.va_state",
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat32",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.QuickCodes.fuel",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Vale.PPC64LE.Decls.va_fuel",
"Vale.PPC64LE.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.va_Mod_vec",
"Vale.PPC64LE.QuickCode.va_Mod_reg",
"Vale.PPC64LE.QuickCode.va_Mod_mem_layout",
"Vale.PPC64LE.QuickCode.va_Mod_mem_heaplet",
"Vale.PPC64LE.QuickCode.va_Mod_ok",
"Vale.PPC64LE.QuickCode.va_Mod_mem",
"Prims.Nil",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.list",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.AES.PPC64LE.GF128_Init.va_code_Keyhash_init",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.tuple3",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCodes.va_wp_sound_code_norm",
"Prims.l_and",
"Vale.PPC64LE.QuickCodes.label",
"Vale.PPC64LE.QuickCodes.va_range1",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Vale.PPC64LE.Decls.modifies_buffer128",
"Vale.PPC64LE.Decls.va_get_mem",
"Vale.AES.OptPublic_BE.hkeys_reqs_pub",
"Vale.Arch.Types.reverse_bytes_quad32_seq",
"Vale.PPC64LE.Decls.s128",
"Vale.AES.AES_BE_s.aes_encrypt_word",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.AES.PPC64LE.GF128_Init.va_qcode_Keyhash_init"
] | [] | false | false | false | false | false | let va_lemma_Keyhash_init va_b0 va_s0 alg key roundkeys_b hkeys_b =
| let va_mods:va_mods_t =
[
va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem
]
in
let va_qc = va_qcode_Keyhash_init va_mods alg key roundkeys_b hkeys_b in
let va_sM, va_fM, va_g =
va_wp_sound_code_norm (va_code_Keyhash_init alg)
va_qc
va_s0
(fun va_s0 va_sM va_g ->
let () = va_g in
label va_range1
"***** POSTCONDITION NOT MET AT line 165 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(va_get_ok va_sM) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 189 column 51 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM)) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 190 column 117 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GF128_Init.vaf *****"
(Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem va_sM)
hkeys_b))
(Vale.AES.AES_BE_s.aes_encrypt_word alg
key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([
va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem
])
va_sM
va_s0;
(va_sM, va_fM) | false |
Steel.ST.C.Types.UserStruct.fsti | Steel.ST.C.Types.UserStruct.struct_field | val struct_field
(#t: Type)
(#sd: struct_def t)
(#v: Ghost.erased t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
: STT
(ref #(norm norm_field_steps (sd.field_desc.fd_type field)) (sd.field_desc.fd_typedef field))
(pts_to r v)
(fun r' ->
((pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field))))
`star`
(pts_to #(norm norm_field_steps (sd.field_desc.fd_type field)) r' (sd.get v field)))
`star`
(has_struct_field r field r')) | val struct_field
(#t: Type)
(#sd: struct_def t)
(#v: Ghost.erased t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
: STT
(ref #(norm norm_field_steps (sd.field_desc.fd_type field)) (sd.field_desc.fd_typedef field))
(pts_to r v)
(fun r' ->
((pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field))))
`star`
(pts_to #(norm norm_field_steps (sd.field_desc.fd_type field)) r' (sd.get v field)))
`star`
(has_struct_field r field r')) | let struct_field
(#t: Type)
(#sd: struct_def t)
(#v: Ghost.erased t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
: STT (ref #(norm norm_field_steps (sd.field_desc.fd_type field)) (sd.field_desc.fd_typedef field))
(pts_to r v)
(fun r' -> pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field))) `star` pts_to #(norm norm_field_steps (sd.field_desc.fd_type field)) r' (sd.get v field) `star` has_struct_field r field r')
= struct_field0
(norm norm_field_steps (sd.field_desc.fd_type field))
r
field
(sd.field_desc.fd_typedef field) | {
"file_name": "lib/steel/c/Steel.ST.C.Types.UserStruct.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 36,
"end_line": 180,
"start_col": 0,
"start_line": 167
} | module Steel.ST.C.Types.UserStruct
open Steel.ST.Util
open Steel.ST.C.Types.Struct.Aux
module Set = FStar.Set
(* This library allows the user to define their own struct type, with
a constructor from field values, and a destructor to field values for
each field. This may be necessary for recursive structs *)
let set_def
(#t: eqtype)
(s: FStar.Set.set t)
(x: t)
: Tot bool
= FStar.Set.mem x s
noextract
let nonempty_set (t: eqtype) =
(s: Set.set t { exists x . set_def s x == true })
noextract
let set_snoc // for associativity reasons
(#t: eqtype) (q: FStar.Set.set t) (a: t) : Pure (nonempty_set t)
(requires True)
(ensures (fun s ->
(forall (x: t). {:pattern FStar.Set.mem x s} FStar.Set.mem x s == (x = a || FStar.Set.mem x q))
))
= q `FStar.Set.union` FStar.Set.singleton a
[@@noextract_to "krml"]
let field_t (s: Set.set string) : Tot eqtype =
(f: string { Set.mem f s })
[@@noextract_to "krml"; norm_field_attr]
inline_for_extraction // for field_desc.fd_type
noeq
type struct_def (t: Type) = {
fields: Set.set string;
field_desc: field_description_gen_t (field_t fields);
mk: ((f: field_t fields) -> Tot (field_desc.fd_type f)) -> Tot t;
get: (t -> (f: field_t fields) -> Tot (field_desc.fd_type f));
get_mk: (phi: ((f: field_t fields) -> Tot (field_desc.fd_type f))) -> (f: field_t fields) -> Lemma
(get (mk phi) f == phi f);
extensionality: (x1: t) -> (x2: t) -> ((f: field_t fields) -> Lemma (get x1 f == get x2 f)) -> Lemma (x1 == x2);
}
let nonempty_set_nonempty_type (x: string) (s: Set.set string) : Lemma
(requires (x `Set.mem` s))
(ensures (exists (x: field_t s) . True))
= Classical.exists_intro (fun (_: field_t s) -> True) x
[@@noextract_to "krml"]
let set_aux
(#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f': field_t sd.fields)
: Tot (sd.field_desc.fd_type f')
= if f = f' then v else sd.get x f'
[@@noextract_to "krml"]
let set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) : Tot t =
sd.mk (set_aux sd x f v)
let get_set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f' : field_t sd.fields) : Lemma
(sd.get (set sd x f v) f' == (if f = f' then v else sd.get x f'))
[SMTPat (sd.get (set sd x f v) f')]
= sd.get_mk (set_aux sd x f v) f'
[@@noextract_to "krml"]
val struct_typedef
(#t: Type)
(sd: struct_def t)
: Tot (typedef t)
val has_struct_field
(#t: Type)
(#sd: struct_def t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(r': ref (sd.field_desc.fd_typedef field))
: Tot vprop
val has_struct_field_dup
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(r': ref (sd.field_desc.fd_typedef field))
: STGhostT unit opened
(has_struct_field r field r')
(fun _ -> has_struct_field r field r' `star` has_struct_field r field r')
val has_struct_field_inj
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(r1 r2: ref (sd.field_desc.fd_typedef field))
: STGhostT unit opened
(has_struct_field r field r1 `star` has_struct_field r field r2)
(fun _ -> has_struct_field r field r1 `star` has_struct_field r field r2 `star` ref_equiv r1 r2)
val has_struct_field_equiv_from
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(r1: ref (struct_typedef sd))
(field: field_t sd.fields)
(r': ref (sd.field_desc.fd_typedef field))
(r2: ref (struct_typedef sd))
: STGhostT unit opened
(ref_equiv r1 r2 `star` has_struct_field r1 field r')
(fun _ -> ref_equiv r1 r2 `star` has_struct_field r2 field r')
val has_struct_field_equiv_to
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(r1' r2': ref (sd.field_desc.fd_typedef field))
: STGhostT unit opened
(ref_equiv r1' r2' `star` has_struct_field r field r1')
(fun _ -> ref_equiv r1' r2' `star` has_struct_field r field r2')
val ghost_struct_field_focus
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(#v: Ghost.erased t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(r': ref (sd.field_desc.fd_typedef field))
: STGhostT unit opened
(has_struct_field r field r' `star` pts_to r v)
(fun _ -> has_struct_field r field r' `star` pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field))) `star` pts_to r' (sd.get v field))
val ghost_struct_field
(#opened: _)
(#t: Type)
(#sd: struct_def t)
(#v: Ghost.erased t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
: STGhostT (Ghost.erased (ref (sd.field_desc.fd_typedef field))) opened
(pts_to r v)
(fun r' -> has_struct_field r field r' `star` pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field))) `star` pts_to r' (sd.get v field))
[@@noextract_to "krml"] // primitive
val struct_field0
(#t: Type)
(t': Type0)
(#sd: struct_def t)
(#v: Ghost.erased t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
(td': typedef t' {
t' == sd.field_desc.fd_type field /\
td' == sd.field_desc.fd_typedef field
})
: STT (ref td')
(pts_to r v)
(fun r' -> has_struct_field r field (coerce_eq () r') `star` pts_to r (set sd (Ghost.reveal v) field (unknown (sd.field_desc.fd_typedef field))) `star` pts_to #_ #(sd.field_desc.fd_typedef field) (coerce_eq () r') (sd.get (Ghost.reveal v) field)) | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.C.Types.Struct.Aux.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.C.Types.UserStruct.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "Set"
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.Struct.Aux",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
r: Steel.ST.C.Types.Base.ref (Steel.ST.C.Types.UserStruct.struct_typedef sd) ->
field: Steel.ST.C.Types.UserStruct.field_t (Mkstruct_def?.fields sd)
-> Steel.ST.Effect.STT
(Steel.ST.C.Types.Base.ref (Mkfield_description_gen_t?.fd_typedef (Mkstruct_def?.field_desc sd)
field)) | Steel.ST.Effect.STT | [] | [] | [
"Steel.ST.C.Types.UserStruct.struct_def",
"FStar.Ghost.erased",
"Steel.ST.C.Types.Base.ref",
"Steel.ST.C.Types.UserStruct.struct_typedef",
"Steel.ST.C.Types.UserStruct.field_t",
"Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__fields",
"Steel.ST.C.Types.UserStruct.struct_field0",
"FStar.Pervasives.norm",
"Steel.ST.C.Types.Base.norm_field_steps",
"Steel.ST.C.Types.Struct.Aux.__proj__Mkfield_description_gen_t__item__fd_type",
"Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__field_desc",
"Steel.ST.C.Types.Struct.Aux.__proj__Mkfield_description_gen_t__item__fd_typedef",
"Steel.ST.C.Types.Base.pts_to",
"Steel.Effect.Common.star",
"FStar.Ghost.hide",
"Steel.ST.C.Types.UserStruct.set",
"FStar.Ghost.reveal",
"Steel.ST.C.Types.Base.unknown",
"Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__get",
"Steel.ST.C.Types.UserStruct.has_struct_field",
"Steel.Effect.Common.vprop"
] | [] | false | true | false | false | false | let struct_field
(#t: Type)
(#sd: struct_def t)
(#v: Ghost.erased t)
(r: ref (struct_typedef sd))
(field: field_t sd.fields)
: STT
(ref #(norm norm_field_steps (sd.field_desc.fd_type field)) (sd.field_desc.fd_typedef field))
(pts_to r v)
(fun r' ->
((pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field))))
`star`
(pts_to #(norm norm_field_steps (sd.field_desc.fd_type field)) r' (sd.get v field)))
`star`
(has_struct_field r field r')) =
| struct_field0 (norm norm_field_steps (sd.field_desc.fd_type field))
r
field
(sd.field_desc.fd_typedef field) | false |
BinomialQueue.fst | BinomialQueue.is_priq | val is_priq : l: BinomialQueue.forest -> Prims.logical | let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 62,
"end_line": 84,
"start_col": 0,
"start_line": 84
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: BinomialQueue.forest -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"BinomialQueue.forest",
"Prims.l_and",
"BinomialQueue.is_binomial_queue",
"BinomialQueue.is_compact",
"Prims.logical"
] | [] | false | false | false | true | true | let is_priq (l: forest) =
| is_binomial_queue 1 l /\ is_compact l | false |
|
BinomialQueue.fst | BinomialQueue.priq | val priq : Type0 | val priq : Type0 | let priq = l:forest{is_priq l} | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 30,
"end_line": 88,
"start_col": 0,
"start_line": 88
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | Type0 | Prims.Tot | [
"total"
] | [] | [
"BinomialQueue.forest",
"BinomialQueue.is_priq"
] | [] | false | false | false | true | true | let priq =
| l: forest{is_priq l} | false |
BinomialQueue.fst | BinomialQueue.is_compact | val is_compact : l: BinomialQueue.forest -> Prims.logical | let is_compact (l:forest) = l == [] \/ Internal? (L.last l) | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 59,
"end_line": 82,
"start_col": 0,
"start_line": 82
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: BinomialQueue.forest -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"BinomialQueue.forest",
"Prims.l_or",
"Prims.eq2",
"Prims.list",
"BinomialQueue.tree",
"Prims.Nil",
"Prims.b2t",
"BinomialQueue.uu___is_Internal",
"FStar.List.Tot.Base.last",
"Prims.logical"
] | [] | false | false | false | true | true | let is_compact (l: forest) =
| l == [] \/ Internal? (L.last l) | false |
|
BinomialQueue.fst | BinomialQueue.last_cons | val last_cons (#a: Type) (x: a) (l: list a)
: Lemma (requires Cons? l) (ensures L.last (x :: l) == L.last l) [SMTPat (L.last (x :: l))] | val last_cons (#a: Type) (x: a) (l: list a)
: Lemma (requires Cons? l) (ensures L.last (x :: l) == L.last l) [SMTPat (L.last (x :: l))] | let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"end_line": 33,
"start_col": 0,
"start_line": 25
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: a -> l: Prims.list a
-> FStar.Pervasives.Lemma (requires Cons? l)
(ensures FStar.List.Tot.Base.last (x :: l) == FStar.List.Tot.Base.last l)
[SMTPat (FStar.List.Tot.Base.last (x :: l))] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.list",
"BinomialQueue.last_cons",
"Prims.unit",
"Prims.b2t",
"Prims.uu___is_Cons",
"Prims.squash",
"Prims.eq2",
"FStar.List.Tot.Base.last",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [
"recursion"
] | false | false | true | false | false | let rec last_cons (#a: Type) (x: a) (l: list a)
: Lemma (requires Cons? l) (ensures L.last (x :: l) == L.last l) [SMTPat (L.last (x :: l))] =
| match l with
| [_] -> ()
| _ :: tl -> last_cons x tl | false |
BinomialQueue.fst | BinomialQueue.pow2heap_pred | val pow2heap_pred (d: nat) (upper_bound: key_t) (t: tree) : prop | val pow2heap_pred (d: nat) (upper_bound: key_t) (t: tree) : prop | let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 43,
"end_line": 56,
"start_col": 0,
"start_line": 49
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: Prims.nat -> upper_bound: BinomialQueue.key_t -> t: BinomialQueue.tree -> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"BinomialQueue.key_t",
"BinomialQueue.tree",
"Prims.eq2",
"Prims.int",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_LessThanOrEqual",
"BinomialQueue.pow2heap_pred",
"Prims.op_Subtraction",
"Prims.prop"
] | [
"recursion"
] | false | false | false | true | true | let rec pow2heap_pred (d: nat) (upper_bound: key_t) (t: tree) : prop =
| match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\ k <= upper_bound /\ pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right | false |
BinomialQueue.fst | BinomialQueue.is_pow2heap | val is_pow2heap (d: pos) (t: tree) : prop | val is_pow2heap (d: pos) (t: tree) : prop | let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 65,
"start_col": 0,
"start_line": 62
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: Prims.pos -> t: BinomialQueue.tree -> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"Prims.pos",
"BinomialQueue.tree",
"BinomialQueue.key_t",
"BinomialQueue.pow2heap_pred",
"Prims.op_Subtraction",
"Prims.l_False",
"Prims.prop"
] | [] | false | false | false | true | true | let is_pow2heap (d: pos) (t: tree) : prop =
| match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False | false |
Steel.GhostMonotonicHigherReference.fst | Steel.GhostMonotonicHigherReference.elim_pure | val elim_pure (#a #uses #p #f: _) (r: ref a p) (v: a) (h: (history a p))
: SteelGhostT (_: unit{history_val h v f}) uses (pts_to_body r f v h) (fun _ -> PR.pts_to r h) | val elim_pure (#a #uses #p #f: _) (r: ref a p) (v: a) (h: (history a p))
: SteelGhostT (_: unit{history_val h v f}) uses (pts_to_body r f v h) (fun _ -> PR.pts_to r h) | let elim_pure #a #uses #p #f
(r:ref a p)
(v:a)
(h:(history a p))
: SteelGhostT (_:unit{history_val h v f})
uses
(pts_to_body r f v h)
(fun _ -> PR.pts_to r h)
= let _ = extract_pure r v h in
drop (pure (history_val h v f)) | {
"file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 35,
"end_line": 95,
"start_col": 0,
"start_line": 86
} | (*
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.GhostMonotonicHigherReference
open FStar.Ghost
open FStar.PCM
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.GhostPCMReference
open Steel.FractionalPermission
open Steel.Preorder
module Preorder = FStar.Preorder
module Q = Steel.Preorder
module M = Steel.Memory
module PR = Steel.GhostPCMReference
module A = Steel.Effect.Atomic
open FStar.Real
#set-options "--ide_id_info_off"
let ref a p = PR.ref (history a p) pcm_history
[@@__reduce__]
let pts_to_body #a #p (r:ref a p) (f:perm) (v:a) (h:history a p) =
PR.pts_to r h `star`
pure (history_val h v f)
let pts_to' (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v: a) =
h_exists (pts_to_body r f v)
let pts_to_sl r f v = hp_of (pts_to' r f v)
let intro_pure #opened #a #p #f
(r:ref a p)
(v:a)
(h:history a p { history_val h v f })
: SteelGhostT unit opened
(PR.pts_to r h)
(fun _ -> pts_to_body r f v h)
= A.intro_pure (history_val h v f)
let intro_pure_full #opened #a #p #f
(r:ref a p)
(v:a)
(h:history a p { history_val h v f })
: SteelGhostT unit opened
(PR.pts_to r h)
(fun _ -> pts_to r f v)
= intro_pure #_ #a #p #f r v h;
intro_exists h (pts_to_body r f v)
let alloc #_ (#a:Type) (p:Preorder.preorder a) (v:a)
= let h = Current [v] full_perm in
assert (compatible pcm_history h h);
let x : ref a p = alloc h in
intro_pure_full x v h;
x
let extract_pure #a #uses #p #f
(r:ref a p)
(v:a)
(h:(history a p))
: SteelGhostT (_:unit{history_val h v f})
uses
(pts_to_body r f v h)
(fun _ -> pts_to_body r f v h)
= elim_pure (history_val h v f);
A.intro_pure (history_val h v f) | {
"checked_file": "/",
"dependencies": [
"Steel.Preorder.fst.checked",
"Steel.Memory.fsti.checked",
"Steel.GhostPCMReference.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.GhostMonotonicHigherReference.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Real",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Effect.Atomic",
"short_module": "A"
},
{
"abbrev": true,
"full_module": "Steel.GhostPCMReference",
"short_module": "PR"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Steel.Preorder",
"short_module": "Q"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"abbrev": false,
"full_module": "Steel.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.GhostPCMReference",
"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.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"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": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | r: Steel.GhostMonotonicHigherReference.ref a p -> v: a -> h: Steel.Preorder.history a p
-> Steel.Effect.Atomic.SteelGhostT
(_: Prims.unit{Steel.Preorder.history_val h (FStar.Ghost.hide v) f}) | Steel.Effect.Atomic.SteelGhostT | [] | [] | [
"Steel.Memory.inames",
"FStar.Preorder.preorder",
"Steel.FractionalPermission.perm",
"Steel.GhostMonotonicHigherReference.ref",
"Steel.Preorder.history",
"Steel.Effect.Atomic.drop",
"Steel.Effect.Common.pure",
"Steel.Preorder.history_val",
"FStar.Ghost.hide",
"Prims.unit",
"Steel.GhostMonotonicHigherReference.extract_pure",
"Steel.GhostMonotonicHigherReference.pts_to_body",
"Steel.GhostPCMReference.pts_to",
"Steel.Preorder.pcm_history",
"Steel.Effect.Common.vprop"
] | [] | false | true | false | false | false | let elim_pure #a #uses #p #f (r: ref a p) (v: a) (h: (history a p))
: SteelGhostT (_: unit{history_val h v f}) uses (pts_to_body r f v h) (fun _ -> PR.pts_to r h) =
| let _ = extract_pure r v h in
drop (pure (history_val h v f)) | false |
BinomialQueue.fst | BinomialQueue.empty | val empty : priq | val empty : priq | let empty = [] | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 90,
"start_col": 0,
"start_line": 90
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | BinomialQueue.priq | Prims.Tot | [
"total"
] | [] | [
"Prims.Nil",
"BinomialQueue.tree"
] | [] | false | false | false | true | false | let empty =
| [] | false |
BinomialQueue.fst | BinomialQueue.is_binomial_queue | val is_binomial_queue (d: pos) (l: forest) : Tot prop (decreases l) | val is_binomial_queue (d: pos) (l: forest) : Tot prop (decreases l) | let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 66,
"end_line": 77,
"start_col": 0,
"start_line": 71
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: Prims.pos -> l: BinomialQueue.forest -> Prims.Tot Prims.prop | Prims.Tot | [
"total",
""
] | [] | [
"Prims.pos",
"BinomialQueue.forest",
"Prims.l_True",
"BinomialQueue.tree",
"Prims.list",
"Prims.l_and",
"Prims.l_or",
"Prims.b2t",
"BinomialQueue.uu___is_Leaf",
"BinomialQueue.is_pow2heap",
"BinomialQueue.is_binomial_queue",
"Prims.op_Addition",
"Prims.prop"
] | [
"recursion"
] | false | false | false | true | true | let rec is_binomial_queue (d: pos) (l: forest) : Tot prop (decreases l) =
| match l with
| [] -> True
| hd :: tl -> (Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl | false |
BinomialQueue.fst | BinomialQueue.mk_compact | val mk_compact (l: forest) : forest | val mk_compact (l: forest) : forest | let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl) | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 28,
"end_line": 106,
"start_col": 0,
"start_line": 100
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: BinomialQueue.forest -> BinomialQueue.forest | Prims.Tot | [
"total"
] | [] | [
"BinomialQueue.forest",
"Prims.Nil",
"BinomialQueue.tree",
"Prims.list",
"BinomialQueue.all_leaf",
"Prims.bool",
"Prims.Cons",
"BinomialQueue.mk_compact"
] | [
"recursion"
] | false | false | false | true | false | let rec mk_compact (l: forest) : forest =
| match l with
| [] -> []
| _ ->
if all_leaf l
then []
else
let hd :: tl = l in
hd :: (mk_compact tl) | false |
BinomialQueue.fst | BinomialQueue.all_leaf | val all_leaf (l: forest{Cons? l}) : bool | val all_leaf (l: forest{Cons? l}) : bool | let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 98,
"start_col": 0,
"start_line": 94
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: BinomialQueue.forest{Cons? l} -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"BinomialQueue.forest",
"Prims.b2t",
"Prims.uu___is_Cons",
"BinomialQueue.tree",
"Prims.list",
"BinomialQueue.all_leaf",
"Prims.bool"
] | [
"recursion"
] | false | false | false | false | false | let rec all_leaf (l: forest{Cons? l}) : bool =
| match l with
| [Leaf] -> true
| Leaf :: tl -> all_leaf tl
| _ -> false | false |
BinomialQueue.fst | BinomialQueue.mk_compact_preserves_binomial_queue | val mk_compact_preserves_binomial_queue (d: pos) (l: forest)
: Lemma (requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] | val mk_compact_preserves_binomial_queue (d: pos) (l: forest)
: Lemma (requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] | let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l) | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 61,
"end_line": 130,
"start_col": 0,
"start_line": 120
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: Prims.pos -> l: BinomialQueue.forest
-> FStar.Pervasives.Lemma (requires BinomialQueue.is_binomial_queue d l)
(ensures BinomialQueue.is_binomial_queue d (BinomialQueue.mk_compact l))
(decreases l)
[SMTPat (BinomialQueue.is_binomial_queue d (BinomialQueue.mk_compact l))] | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Prims.pos",
"BinomialQueue.forest",
"Prims.list",
"BinomialQueue.tree",
"BinomialQueue.all_leaf",
"Prims.bool",
"BinomialQueue.mk_compact_preserves_binomial_queue",
"Prims.op_Addition",
"FStar.List.Tot.Base.tl",
"Prims.unit",
"BinomialQueue.is_binomial_queue",
"Prims.squash",
"BinomialQueue.mk_compact",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.prop",
"Prims.Nil"
] | [
"recursion"
] | false | false | true | false | false | let rec mk_compact_preserves_binomial_queue (d: pos) (l: forest)
: Lemma (requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
| match l with
| [] -> ()
| _ -> if all_leaf l then () else mk_compact_preserves_binomial_queue (d + 1) (L.tl l) | false |
BinomialQueue.fst | BinomialQueue.mk_compact_correctness | val mk_compact_correctness (l: forest)
: Lemma (is_compact (mk_compact l)) [SMTPat (is_compact (mk_compact l))] | val mk_compact_correctness (l: forest)
: Lemma (is_compact (mk_compact l)) [SMTPat (is_compact (mk_compact l))] | let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l) | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 40,
"end_line": 118,
"start_col": 0,
"start_line": 110
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: BinomialQueue.forest
-> FStar.Pervasives.Lemma (ensures BinomialQueue.is_compact (BinomialQueue.mk_compact l))
[SMTPat (BinomialQueue.is_compact (BinomialQueue.mk_compact l))] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"BinomialQueue.forest",
"Prims.list",
"BinomialQueue.tree",
"BinomialQueue.all_leaf",
"Prims.bool",
"BinomialQueue.mk_compact_correctness",
"FStar.List.Tot.Base.tl",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"BinomialQueue.is_compact",
"BinomialQueue.mk_compact",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.logical",
"Prims.Nil"
] | [
"recursion"
] | false | false | true | false | false | let rec mk_compact_correctness (l: forest)
: Lemma (is_compact (mk_compact l)) [SMTPat (is_compact (mk_compact l))] =
| match l with
| [] -> ()
| _ -> if all_leaf l then () else mk_compact_correctness (L.tl l) | false |
Duplex.PingPong.fst | Duplex.PingPong.pingpong | val pingpong:dprot | val pingpong:dprot | let pingpong : dprot =
x <-- send int;
y <-- recv (y:int{y > x});
done | {
"file_name": "share/steel/examples/steel/Duplex.PingPong.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 6,
"end_line": 16,
"start_col": 0,
"start_line": 13
} | module Duplex.PingPong
open FStar.PCM
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.Channel.Protocol
open Duplex.PCM
////////////////////////////////////////////////////////////////////////////////
// An example
//////////////////////////////////////////////////////////////////////////////// | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"Steel.Channel.Protocol.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"Duplex.PCM.fsti.checked"
],
"interface_file": false,
"source_file": "Duplex.PingPong.fst"
} | [
{
"abbrev": false,
"full_module": "Duplex.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Channel.Protocol",
"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.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Duplex",
"short_module": null
},
{
"abbrev": false,
"full_module": "Duplex",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | Duplex.PCM.dprot | Prims.Tot | [
"total"
] | [] | [
"Duplex.PCM.bind",
"Prims.int",
"Prims.unit",
"Duplex.PCM.send",
"Prims.b2t",
"Prims.op_GreaterThan",
"Duplex.PCM.recv",
"Duplex.PCM.done",
"Duplex.PCM.nl_protocol"
] | [] | false | false | false | true | false | let pingpong:dprot =
| x <-- send int ;
y <-- recv (y: int{y > x}) ;
done | false |
BinomialQueue.fst | BinomialQueue.smash | val smash (d: pos) (t1 t2: tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) | val smash (d: pos) (t1 t2: tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) | let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 51,
"end_line": 144,
"start_col": 0,
"start_line": 135
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: Prims.pos -> t1: BinomialQueue.tree -> t2: BinomialQueue.tree -> Prims.Pure BinomialQueue.tree | Prims.Pure | [] | [] | [
"Prims.pos",
"BinomialQueue.tree",
"FStar.Pervasives.Native.Mktuple2",
"BinomialQueue.key_t",
"Prims.op_LessThanOrEqual",
"BinomialQueue.Internal",
"BinomialQueue.Leaf",
"Prims.bool",
"Prims.l_and",
"BinomialQueue.is_pow2heap",
"Prims.op_Addition"
] | [] | false | false | false | false | false | let smash (d: pos) (t1 t2: tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
| match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf | false |
BinomialQueue.fst | BinomialQueue.carry | val carry (d: pos) (q: forest) (t: tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) | val carry (d: pos) (q: forest) (t: tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) | let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 11,
"end_line": 160,
"start_col": 0,
"start_line": 150
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: Prims.pos -> q: BinomialQueue.forest -> t: BinomialQueue.tree -> Prims.Pure BinomialQueue.forest | Prims.Pure | [
""
] | [] | [
"Prims.pos",
"BinomialQueue.forest",
"BinomialQueue.tree",
"Prims.Cons",
"Prims.Nil",
"Prims.list",
"BinomialQueue.Leaf",
"BinomialQueue.carry",
"Prims.op_Addition",
"BinomialQueue.smash",
"Prims.l_and",
"BinomialQueue.is_binomial_queue",
"BinomialQueue.is_pow2heap"
] | [
"recursion"
] | false | false | false | false | false | let rec carry (d: pos) (q: forest) (t: tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
| match q with
| [] -> [t]
| Leaf :: tl -> t :: tl
| hd :: tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf :: q | false |
BinomialQueue.fst | BinomialQueue.insert | val insert : key_t -> priq -> priq | val insert : key_t -> priq -> priq | let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 198,
"start_col": 0,
"start_line": 196
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: BinomialQueue.key_t -> q: BinomialQueue.priq -> BinomialQueue.priq | Prims.Tot | [
"total"
] | [] | [
"BinomialQueue.key_t",
"BinomialQueue.priq",
"BinomialQueue.mk_compact",
"BinomialQueue.forest",
"BinomialQueue.carry",
"BinomialQueue.Internal",
"BinomialQueue.Leaf"
] | [] | false | false | false | true | false | let insert x q =
| let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l | false |
LListReverse.fst | LListReverse.llist_nil_is_null | val llist_nil_is_null (#opened: _) (l: Ghost.erased (list U64.t)) (p: ref llist_cell)
: STGhost unit opened (llist l p) (fun _ -> llist l p) True (fun _ -> (p == null <==> Nil? l)) | val llist_nil_is_null (#opened: _) (l: Ghost.erased (list U64.t)) (p: ref llist_cell)
: STGhost unit opened (llist l p) (fun _ -> llist l p) True (fun _ -> (p == null <==> Nil? l)) | let llist_nil_is_null
(#opened: _)
(l: Ghost.erased (list U64.t))
(p: ref llist_cell)
: STGhost unit opened
(llist l p)
(fun _ -> llist l p)
True
(fun _ -> (p == null <==> Nil? l))
= if Nil? l
then begin
rewrite (llist l p) (llist_nil p);
let _ = gen_elim () in
rewrite (llist_nil p) (llist l p)
end else begin
let a :: q = Ghost.reveal l in
rewrite (llist l p) (llist_cons a (llist q) p);
let _ = gen_elim () in
pts_to_not_null p;
rewrite (llist_cons a (llist q) p) (llist l p)
end | {
"file_name": "share/steel/tests/krml/LListReverse.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 5,
"end_line": 62,
"start_col": 0,
"start_line": 42
} | module LListReverse
open Steel.ST.GenElim
open Steel.ST.Reference
open Steel.ST.Loops
module U64 = FStar.UInt64
let main () = C.EXIT_SUCCESS // dummy for compilation
noeq
type llist_cell = {
value: U64.t;
next: ref llist_cell;
}
[@@__reduce__]
let llist_nil
(p: ref llist_cell)
: Tot vprop
= pure (p == null)
[@@__reduce__]
let llist_cons
(a: U64.t)
(llist: (ref llist_cell -> Tot vprop))
(p: ref llist_cell)
: Tot vprop
= exists_ (fun c ->
pts_to p full_perm c `star`
pure (c.value == a) `star`
llist c.next
)
let rec llist
(l: Ghost.erased (list U64.t))
: Tot (ref llist_cell -> vprop)
(decreases Ghost.reveal l)
= match Ghost.reveal l with
| [] -> llist_nil
| a :: q -> llist_cons a (llist q) | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Reference.fsti.checked",
"Steel.ST.Loops.fsti.checked",
"Steel.ST.GenElim.fsti.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"C.fst.checked"
],
"interface_file": false,
"source_file": "LListReverse.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "Steel.ST.Loops",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Reference",
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
l: FStar.Ghost.erased (Prims.list FStar.UInt64.t) ->
p: Steel.ST.Reference.ref LListReverse.llist_cell
-> Steel.ST.Effect.Ghost.STGhost Prims.unit | Steel.ST.Effect.Ghost.STGhost | [] | [] | [
"Steel.Memory.inames",
"FStar.Ghost.erased",
"Prims.list",
"FStar.UInt64.t",
"Steel.ST.Reference.ref",
"LListReverse.llist_cell",
"Prims.uu___is_Nil",
"FStar.Ghost.reveal",
"Steel.ST.Util.rewrite",
"LListReverse.llist_nil",
"LListReverse.llist",
"Prims.unit",
"Steel.ST.GenElim.gen_elim",
"Steel.ST.Util.pure",
"Prims.eq2",
"Steel.ST.Reference.null",
"Steel.Effect.Common.emp",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Prims.bool",
"LListReverse.llist_cons",
"FStar.Ghost.hide",
"Steel.ST.Reference.pts_to_not_null",
"Steel.FractionalPermission.full_perm",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.VStar",
"Steel.ST.Reference.pts_to",
"LListReverse.__proj__Mkllist_cell__item__value",
"LListReverse.__proj__Mkllist_cell__item__next",
"Steel.Effect.Common.star",
"Prims.l_and",
"Prims.l_True",
"Prims.l_iff",
"Prims.b2t"
] | [] | false | true | false | false | false | let llist_nil_is_null (#opened: _) (l: Ghost.erased (list U64.t)) (p: ref llist_cell)
: STGhost unit opened (llist l p) (fun _ -> llist l p) True (fun _ -> (p == null <==> Nil? l)) =
| if Nil? l
then
(rewrite (llist l p) (llist_nil p);
let _ = gen_elim () in
rewrite (llist_nil p) (llist l p))
else
let a :: q = Ghost.reveal l in
rewrite (llist l p) (llist_cons a (llist q) p);
let _ = gen_elim () in
pts_to_not_null p;
rewrite (llist_cons a (llist q) p) (llist l p) | false |
BinomialQueue.fst | BinomialQueue.join | val join (d: pos) (p q: forest) (c: tree)
: Pure forest
(requires is_binomial_queue d p /\ is_binomial_queue d q /\ (Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) | val join (d: pos) (p q: forest) (c: tree)
: Pure forest
(requires is_binomial_queue d p /\ is_binomial_queue d q /\ (Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) | let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q)) | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 51,
"end_line": 192,
"start_col": 0,
"start_line": 167
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: Prims.pos -> p: BinomialQueue.forest -> q: BinomialQueue.forest -> c: BinomialQueue.tree
-> Prims.Pure BinomialQueue.forest | Prims.Pure | [
""
] | [] | [
"Prims.pos",
"BinomialQueue.forest",
"BinomialQueue.tree",
"FStar.Pervasives.Native.Mktuple3",
"Prims.list",
"BinomialQueue.carry",
"Prims.Cons",
"BinomialQueue.join",
"Prims.op_Addition",
"BinomialQueue.Leaf",
"BinomialQueue.smash",
"Prims.l_and",
"BinomialQueue.is_binomial_queue",
"Prims.l_or",
"Prims.b2t",
"BinomialQueue.uu___is_Leaf",
"BinomialQueue.is_pow2heap"
] | [
"recursion"
] | false | false | false | false | false | let rec join (d: pos) (p q: forest) (c: tree)
: Pure forest
(requires is_binomial_queue d p /\ is_binomial_queue d q /\ (Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
| match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf :: tl_p, Leaf :: tl_q, _ -> c :: (join (d + 1) tl_p tl_q Leaf)
| hd_p :: tl_p, Leaf :: tl_q, Leaf -> hd_p :: (join (d + 1) tl_p tl_q Leaf)
| Leaf :: tl_p, hd_q :: tl_q, Leaf -> hd_q :: (join (d + 1) tl_p tl_q Leaf)
| Leaf :: tl_p, hd_q :: tl_q, _ -> Leaf :: (join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p :: tl_p, Leaf :: tl_q, _ -> Leaf :: (join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p :: tl_p, hd_q :: tl_q, c -> c :: (join (d + 1) tl_p tl_q (smash d hd_p hd_q)) | false |
BinomialQueue.fst | BinomialQueue.repr | val repr (q:priq) (s:ms) : prop | val repr (q:priq) (s:ms) : prop | let repr q s = repr_l q s | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 25,
"end_line": 327,
"start_col": 0,
"start_line": 327
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
///
let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right)
/// delete_max finds the maximum key in the forest,
/// deletes it from its tree, and joins the remaining forests
let delete_max q =
match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r)
/// merge is just join with Leaf as the carry
let merge p q =
let l = join 1 p q Leaf in
mk_compact l
/// Towards defining repr
let rec keys_of_tree (t:tree) : ms =
match t with
| Leaf -> ms_empty
| Internal left k right ->
ms_append (keys_of_tree left)
(ms_cons k (keys_of_tree right))
let rec keys (q:forest) : ms =
match q with
| [] -> ms_empty
| hd::tl -> ms_append (keys_of_tree hd) (keys tl)
let repr_t (t:tree) (l:ms) : prop =
permutation (keys_of_tree t) l
let repr_l (q:forest) (s:ms) : prop =
permutation (keys q) s
/// The main repr predicate saying s is a permutation of (keys q) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | q: BinomialQueue.priq -> s: BinomialQueue.ms -> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"BinomialQueue.priq",
"BinomialQueue.ms",
"BinomialQueue.repr_l",
"Prims.prop"
] | [] | false | false | false | true | true | let repr q s =
| repr_l q s | false |
BinomialQueue.fst | BinomialQueue.heap_delete_max | val heap_delete_max (d: pos) (t: tree)
: Pure priq (requires is_pow2heap d t) (ensures fun q -> L.length q == d - 1) | val heap_delete_max (d: pos) (t: tree)
: Pure priq (requires is_pow2heap d t) (ensures fun q -> L.length q == d - 1) | let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 48,
"end_line": 262,
"start_col": 0,
"start_line": 256
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: Prims.pos -> t: BinomialQueue.tree -> Prims.Pure BinomialQueue.priq | Prims.Pure | [] | [] | [
"Prims.pos",
"BinomialQueue.tree",
"BinomialQueue.key_t",
"BinomialQueue.unzip",
"Prims.op_Subtraction",
"BinomialQueue.priq",
"BinomialQueue.is_pow2heap",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length"
] | [] | false | false | false | false | false | let heap_delete_max (d: pos) (t: tree)
: Pure priq (requires is_pow2heap d t) (ensures fun q -> L.length q == d - 1) =
| match t with | Internal left k Leaf -> unzip (d - 1) k left | false |
BinomialQueue.fst | BinomialQueue.keys_of_tree | val keys_of_tree (t: tree) : ms | val keys_of_tree (t: tree) : ms | let rec keys_of_tree (t:tree) : ms =
match t with
| Leaf -> ms_empty
| Internal left k right ->
ms_append (keys_of_tree left)
(ms_cons k (keys_of_tree right)) | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 46,
"end_line": 312,
"start_col": 0,
"start_line": 307
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
///
let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right)
/// delete_max finds the maximum key in the forest,
/// deletes it from its tree, and joins the remaining forests
let delete_max q =
match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r)
/// merge is just join with Leaf as the carry
let merge p q =
let l = join 1 p q Leaf in
mk_compact l
/// Towards defining repr | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: BinomialQueue.tree -> BinomialQueue.ms | Prims.Tot | [
"total"
] | [] | [
"BinomialQueue.tree",
"BinomialQueue.ms_empty",
"BinomialQueue.key_t",
"BinomialQueue.ms_append",
"BinomialQueue.keys_of_tree",
"BinomialQueue.ms_cons",
"BinomialQueue.ms"
] | [
"recursion"
] | false | false | false | true | false | let rec keys_of_tree (t: tree) : ms =
| match t with
| Leaf -> ms_empty
| Internal left k right -> ms_append (keys_of_tree left) (ms_cons k (keys_of_tree right)) | false |
BinomialQueue.fst | BinomialQueue.merge | val merge : priq -> priq -> priq | val merge : priq -> priq -> priq | let merge p q =
let l = join 1 p q Leaf in
mk_compact l | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 303,
"start_col": 0,
"start_line": 301
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
///
let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right)
/// delete_max finds the maximum key in the forest,
/// deletes it from its tree, and joins the remaining forests
let delete_max q =
match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r)
/// merge is just join with Leaf as the carry | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: BinomialQueue.priq -> q: BinomialQueue.priq -> BinomialQueue.priq | Prims.Tot | [
"total"
] | [] | [
"BinomialQueue.priq",
"BinomialQueue.mk_compact",
"BinomialQueue.forest",
"BinomialQueue.join",
"BinomialQueue.Leaf"
] | [] | false | false | false | true | false | let merge p q =
| let l = join 1 p q Leaf in
mk_compact l | false |
BinomialQueue.fst | BinomialQueue.find_max | val find_max (max: option key_t) (q: forest) : Tot (option key_t) (decreases q) | val find_max (max: option key_t) (q: forest) : Tot (option key_t) (decreases q) | let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 67,
"end_line": 214,
"start_col": 0,
"start_line": 206
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | max: FStar.Pervasives.Native.option BinomialQueue.key_t -> q: BinomialQueue.forest
-> Prims.Tot (FStar.Pervasives.Native.option BinomialQueue.key_t) | Prims.Tot | [
"total",
""
] | [] | [
"FStar.Pervasives.Native.option",
"BinomialQueue.key_t",
"BinomialQueue.forest",
"Prims.list",
"BinomialQueue.tree",
"BinomialQueue.find_max",
"FStar.Pervasives.Native.Some",
"Prims.op_LessThan",
"Prims.bool"
] | [
"recursion"
] | false | false | false | true | false | let rec find_max (max: option key_t) (q: forest) : Tot (option key_t) (decreases q) =
| match q with
| [] -> max
| Leaf :: q -> find_max max q
| Internal _ k _ :: q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q | false |
BinomialQueue.fst | BinomialQueue.binomial_queue_append | val binomial_queue_append (d: pos) (q: forest) (t: tree)
: Lemma (requires is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) | val binomial_queue_append (d: pos) (q: forest) (t: tree)
: Lemma (requires is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) | let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 45,
"end_line": 230,
"start_col": 0,
"start_line": 222
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: Prims.pos -> q: BinomialQueue.forest -> t: BinomialQueue.tree
-> FStar.Pervasives.Lemma
(requires
BinomialQueue.is_binomial_queue d q /\
BinomialQueue.is_pow2heap (FStar.List.Tot.Base.length q + d) t)
(ensures BinomialQueue.is_binomial_queue d (q @ [t]))
(decreases q) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Prims.pos",
"BinomialQueue.forest",
"BinomialQueue.tree",
"Prims.list",
"BinomialQueue.binomial_queue_append",
"Prims.op_Addition",
"Prims.unit",
"Prims.l_and",
"BinomialQueue.is_binomial_queue",
"BinomialQueue.is_pow2heap",
"FStar.List.Tot.Base.length",
"Prims.squash",
"FStar.List.Tot.Base.append",
"Prims.Cons",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec binomial_queue_append (d: pos) (q: forest) (t: tree)
: Lemma (requires is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
| match q with
| [] -> ()
| _ :: q -> binomial_queue_append (d + 1) q t | false |
BinomialQueue.fst | BinomialQueue.keys | val keys (q: forest) : ms | val keys (q: forest) : ms | let rec keys (q:forest) : ms =
match q with
| [] -> ms_empty
| hd::tl -> ms_append (keys_of_tree hd) (keys tl) | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 51,
"end_line": 317,
"start_col": 0,
"start_line": 314
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
///
let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right)
/// delete_max finds the maximum key in the forest,
/// deletes it from its tree, and joins the remaining forests
let delete_max q =
match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r)
/// merge is just join with Leaf as the carry
let merge p q =
let l = join 1 p q Leaf in
mk_compact l
/// Towards defining repr
let rec keys_of_tree (t:tree) : ms =
match t with
| Leaf -> ms_empty
| Internal left k right ->
ms_append (keys_of_tree left)
(ms_cons k (keys_of_tree right)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | q: BinomialQueue.forest -> BinomialQueue.ms | Prims.Tot | [
"total"
] | [] | [
"BinomialQueue.forest",
"BinomialQueue.ms_empty",
"BinomialQueue.tree",
"Prims.list",
"BinomialQueue.ms_append",
"BinomialQueue.keys_of_tree",
"BinomialQueue.keys",
"BinomialQueue.ms"
] | [
"recursion"
] | false | false | false | true | false | let rec keys (q: forest) : ms =
| match q with
| [] -> ms_empty
| hd :: tl -> ms_append (keys_of_tree hd) (keys tl) | false |
BinomialQueue.fst | BinomialQueue.unzip | val unzip (d: nat) (upper_bound: key_t) (t: tree)
: Pure priq (requires pow2heap_pred d upper_bound t) (ensures fun q -> L.length q == d) | val unzip (d: nat) (upper_bound: key_t) (t: tree)
: Pure priq (requires pow2heap_pred d upper_bound t) (ensures fun q -> L.length q == d) | let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf] | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 37,
"end_line": 252,
"start_col": 0,
"start_line": 240
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important? | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: Prims.nat -> upper_bound: BinomialQueue.key_t -> t: BinomialQueue.tree
-> Prims.Pure BinomialQueue.priq | Prims.Pure | [] | [] | [
"Prims.nat",
"BinomialQueue.key_t",
"BinomialQueue.tree",
"Prims.Nil",
"FStar.List.Tot.Base.append",
"Prims.Cons",
"BinomialQueue.Internal",
"BinomialQueue.Leaf",
"Prims.unit",
"FStar.List.Tot.Properties.lemma_append_last",
"FStar.List.Tot.Properties.append_length",
"BinomialQueue.binomial_queue_append",
"BinomialQueue.priq",
"BinomialQueue.unzip",
"Prims.op_Subtraction",
"BinomialQueue.pow2heap_pred",
"Prims.eq2",
"FStar.List.Tot.Base.length"
] | [
"recursion"
] | false | false | false | false | false | let rec unzip (d: nat) (upper_bound: key_t) (t: tree)
: Pure priq (requires pow2heap_pred d upper_bound t) (ensures fun q -> L.length q == d) =
| match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf] | false |
BinomialQueue.fst | BinomialQueue.repr_t | val repr_t (t: tree) (l: ms) : prop | val repr_t (t: tree) (l: ms) : prop | let repr_t (t:tree) (l:ms) : prop =
permutation (keys_of_tree t) l | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 32,
"end_line": 320,
"start_col": 0,
"start_line": 319
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
///
let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right)
/// delete_max finds the maximum key in the forest,
/// deletes it from its tree, and joins the remaining forests
let delete_max q =
match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r)
/// merge is just join with Leaf as the carry
let merge p q =
let l = join 1 p q Leaf in
mk_compact l
/// Towards defining repr
let rec keys_of_tree (t:tree) : ms =
match t with
| Leaf -> ms_empty
| Internal left k right ->
ms_append (keys_of_tree left)
(ms_cons k (keys_of_tree right))
let rec keys (q:forest) : ms =
match q with
| [] -> ms_empty
| hd::tl -> ms_append (keys_of_tree hd) (keys tl) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: BinomialQueue.tree -> l: BinomialQueue.ms -> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"BinomialQueue.tree",
"BinomialQueue.ms",
"BinomialQueue.permutation",
"BinomialQueue.keys_of_tree",
"Prims.prop"
] | [] | false | false | false | true | true | let repr_t (t: tree) (l: ms) : prop =
| permutation (keys_of_tree t) l | false |
BinomialQueue.fst | BinomialQueue.delete_max | val delete_max : priq -> option (key_t & priq) | val delete_max : priq -> option (key_t & priq) | let delete_max q =
match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r) | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 26,
"end_line": 297,
"start_col": 0,
"start_line": 290
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
///
let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right)
/// delete_max finds the maximum key in the forest,
/// deletes it from its tree, and joins the remaining forests | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | q: BinomialQueue.priq -> FStar.Pervasives.Native.option (BinomialQueue.key_t * BinomialQueue.priq) | Prims.Tot | [
"total"
] | [] | [
"BinomialQueue.priq",
"BinomialQueue.find_max",
"FStar.Pervasives.Native.None",
"BinomialQueue.key_t",
"FStar.Pervasives.Native.tuple2",
"BinomialQueue.forest",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"BinomialQueue.mk_compact",
"Prims.unit",
"BinomialQueue.mk_compact_correctness",
"BinomialQueue.join",
"BinomialQueue.Leaf",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple3",
"BinomialQueue.delete_max_aux"
] | [] | false | false | false | true | false | let delete_max q =
| match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r) | false |
BinomialQueue.fst | BinomialQueue.repr_l | val repr_l (q: forest) (s: ms) : prop | val repr_l (q: forest) (s: ms) : prop | let repr_l (q:forest) (s:ms) : prop =
permutation (keys q) s | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 24,
"end_line": 323,
"start_col": 0,
"start_line": 322
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
///
let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right)
/// delete_max finds the maximum key in the forest,
/// deletes it from its tree, and joins the remaining forests
let delete_max q =
match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r)
/// merge is just join with Leaf as the carry
let merge p q =
let l = join 1 p q Leaf in
mk_compact l
/// Towards defining repr
let rec keys_of_tree (t:tree) : ms =
match t with
| Leaf -> ms_empty
| Internal left k right ->
ms_append (keys_of_tree left)
(ms_cons k (keys_of_tree right))
let rec keys (q:forest) : ms =
match q with
| [] -> ms_empty
| hd::tl -> ms_append (keys_of_tree hd) (keys tl)
let repr_t (t:tree) (l:ms) : prop =
permutation (keys_of_tree t) l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | q: BinomialQueue.forest -> s: BinomialQueue.ms -> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"BinomialQueue.forest",
"BinomialQueue.ms",
"BinomialQueue.permutation",
"BinomialQueue.keys",
"Prims.prop"
] | [] | false | false | false | true | true | let repr_l (q: forest) (s: ms) : prop =
| permutation (keys q) s | false |
BinomialQueue.fst | BinomialQueue.delete_max_aux | val delete_max_aux (m: key_t) (d: pos) (q: forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) | val delete_max_aux (m: key_t) (d: pos) (q: forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) | let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right) | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 62,
"end_line": 285,
"start_col": 0,
"start_line": 269
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
/// | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: BinomialQueue.key_t -> d: Prims.pos -> q: BinomialQueue.forest
-> Prims.Pure ((BinomialQueue.key_t * BinomialQueue.forest) * BinomialQueue.priq) | Prims.Pure | [
""
] | [] | [
"BinomialQueue.key_t",
"Prims.pos",
"BinomialQueue.forest",
"FStar.Pervasives.Native.Mktuple3",
"BinomialQueue.priq",
"Prims.op_Addition",
"Prims.Nil",
"BinomialQueue.tree",
"Prims.list",
"Prims.Cons",
"BinomialQueue.Leaf",
"FStar.Pervasives.Native.tuple3",
"BinomialQueue.delete_max_aux",
"Prims.op_LessThan",
"BinomialQueue.Internal",
"Prims.bool",
"BinomialQueue.heap_delete_max",
"BinomialQueue.is_binomial_queue",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual"
] | [
"recursion"
] | false | false | false | false | false | let rec delete_max_aux (m: key_t) (d: pos) (q: forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
| match q with
| [] -> m + 1, [], []
| Leaf :: q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf :: q, new_q
| Internal left x right :: q ->
if x < m
then
let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right) :: q, new_q
else x, Leaf :: q, heap_delete_max d (Internal left x right) | false |
Steel.ST.C.Types.Base.fsti | Steel.ST.C.Types.Base.assert_not_null | val assert_not_null (#t: Type) (#opened: _) (#td: typedef t) (#v: Ghost.erased t) (p: ptr td)
: STGhost (squash (~(p == null _)))
opened
(pts_to_or_null p v)
(fun _ -> pts_to p v)
(~(p == null _))
(fun _ -> True) | val assert_not_null (#t: Type) (#opened: _) (#td: typedef t) (#v: Ghost.erased t) (p: ptr td)
: STGhost (squash (~(p == null _)))
opened
(pts_to_or_null p v)
(fun _ -> pts_to p v)
(~(p == null _))
(fun _ -> True) | let assert_not_null
(#t: Type)
(#opened: _)
(#td: typedef t)
(#v: Ghost.erased t)
(p: ptr td)
: STGhost (squash (~ (p == null _))) opened
(pts_to_or_null p v)
(fun _ -> pts_to p v)
(~ (p == null _))
(fun _ -> True)
= rewrite (pts_to_or_null p v) (pts_to p v) | {
"file_name": "lib/steel/c/Steel.ST.C.Types.Base.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 43,
"end_line": 148,
"start_col": 0,
"start_line": 137
} | module Steel.ST.C.Types.Base
open Steel.ST.Util
module P = Steel.FractionalPermission
/// Helper to compose two permissions into one
val prod_perm (p1 p2: P.perm) : Pure P.perm
(requires True)
(ensures (fun p ->
((p1 `P.lesser_equal_perm` P.full_perm /\ p2 `P.lesser_equal_perm` P.full_perm) ==>
p `P.lesser_equal_perm` P.full_perm) /\
p.v == (let open FStar.Real in p1.v *. p2.v)
))
[@@noextract_to "krml"] // proof-only
val typedef (t: Type0) : Type0
inline_for_extraction [@@noextract_to "krml"]
let typeof (#t: Type0) (td: typedef t) : Tot Type0 = t
val fractionable (#t: Type0) (td: typedef t) (x: t) : GTot prop
val mk_fraction (#t: Type0) (td: typedef t) (x: t) (p: P.perm) : Ghost t
(requires (fractionable td x))
(ensures (fun y -> p `P.lesser_equal_perm` P.full_perm ==> fractionable td y))
val mk_fraction_full (#t: Type0) (td: typedef t) (x: t) : Lemma
(requires (fractionable td x))
(ensures (mk_fraction td x P.full_perm == x))
[SMTPat (mk_fraction td x P.full_perm)]
val mk_fraction_compose (#t: Type0) (td: typedef t) (x: t) (p1 p2: P.perm) : Lemma
(requires (fractionable td x /\ p1 `P.lesser_equal_perm` P.full_perm /\ p2 `P.lesser_equal_perm` P.full_perm))
(ensures (mk_fraction td (mk_fraction td x p1) p2 == mk_fraction td x (p1 `prod_perm` p2)))
val full (#t: Type0) (td: typedef t) (v: t) : GTot prop
val uninitialized (#t: Type0) (td: typedef t) : Ghost t
(requires True)
(ensures (fun y -> full td y /\ fractionable td y))
val unknown (#t: Type0) (td: typedef t) : Ghost t
(requires True)
(ensures (fun y -> fractionable td y))
val full_not_unknown
(#t: Type)
(td: typedef t)
(v: t)
: Lemma
(requires (full td v))
(ensures (~ (v == unknown td)))
[SMTPat (full td v)]
val mk_fraction_unknown (#t: Type0) (td: typedef t) (p: P.perm) : Lemma
(ensures (mk_fraction td (unknown td) p == unknown td))
val mk_fraction_eq_unknown (#t: Type0) (td: typedef t) (v: t) (p: P.perm) : Lemma
(requires (fractionable td v /\ mk_fraction td v p == unknown td))
(ensures (v == unknown td))
// To be extracted as: void*
[@@noextract_to "krml"] // primitive
val void_ptr : Type0
// To be extracted as: NULL
[@@noextract_to "krml"] // primitive
val void_null: void_ptr
// To be extracted as: *t
[@@noextract_to "krml"] // primitive
val ptr_gen ([@@@unused] t: Type) : Type0
[@@noextract_to "krml"] // primitive
val null_gen (t: Type) : Tot (ptr_gen t)
val ghost_void_ptr_of_ptr_gen (#[@@@unused] t: Type) (x: ptr_gen t) : GTot void_ptr
val ghost_ptr_gen_of_void_ptr (x: void_ptr) ([@@@unused] t: Type) : GTot (ptr_gen t)
val ghost_void_ptr_of_ptr_gen_of_void_ptr
(x: void_ptr)
(t: Type)
: Lemma
(ghost_void_ptr_of_ptr_gen (ghost_ptr_gen_of_void_ptr x t) == x)
[SMTPat (ghost_void_ptr_of_ptr_gen (ghost_ptr_gen_of_void_ptr x t))]
val ghost_ptr_gen_of_void_ptr_of_ptr_gen
(#t: Type)
(x: ptr_gen t)
: Lemma
(ghost_ptr_gen_of_void_ptr (ghost_void_ptr_of_ptr_gen x) t == x)
[SMTPat (ghost_ptr_gen_of_void_ptr (ghost_void_ptr_of_ptr_gen x) t)]
inline_for_extraction [@@noextract_to "krml"] // primitive
let ptr (#t: Type) (td: typedef t) : Tot Type0 = ptr_gen t
inline_for_extraction [@@noextract_to "krml"] // primitive
let null (#t: Type) (td: typedef t) : Tot (ptr td) = null_gen t
inline_for_extraction [@@noextract_to "krml"]
let ref (#t: Type) (td: typedef t) : Tot Type0 = (p: ptr td { ~ (p == null td) })
val pts_to (#t: Type) (#td: typedef t) (r: ref td) ([@@@smt_fallback] v: Ghost.erased t) : vprop
let pts_to_or_null
(#t: Type) (#td: typedef t) (p: ptr td) (v: Ghost.erased t) : vprop
= if FStar.StrongExcludedMiddle.strong_excluded_middle (p == null _)
then emp
else pts_to p v
[@@noextract_to "krml"] // primitive
val is_null
(#t: Type)
(#opened: _)
(#td: typedef t)
(#v: Ghost.erased t)
(p: ptr td)
: STAtomicBase bool false opened Unobservable
(pts_to_or_null p v)
(fun _ -> pts_to_or_null p v)
(True)
(fun res -> res == true <==> p == null _)
let assert_null
(#t: Type)
(#opened: _)
(#td: typedef t)
(#v: Ghost.erased t)
(p: ptr td)
: STGhost unit opened
(pts_to_or_null p v)
(fun _ -> emp)
(p == null _)
(fun _ -> True)
= rewrite (pts_to_or_null p v) emp | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.C.Types.Base.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.ptr td
-> Steel.ST.Effect.Ghost.STGhost (Prims.squash (~(p == Steel.ST.C.Types.Base.null td))) | Steel.ST.Effect.Ghost.STGhost | [] | [] | [
"Steel.Memory.inames",
"Steel.ST.C.Types.Base.typedef",
"FStar.Ghost.erased",
"Steel.ST.C.Types.Base.ptr",
"Steel.ST.Util.rewrite",
"Steel.ST.C.Types.Base.pts_to_or_null",
"Steel.ST.C.Types.Base.pts_to",
"Prims.unit",
"Prims.squash",
"Prims.l_not",
"Prims.eq2",
"Steel.ST.C.Types.Base.null",
"Steel.Effect.Common.vprop",
"Prims.l_True"
] | [] | false | true | true | false | false | let assert_not_null (#t: Type) (#opened: _) (#td: typedef t) (#v: Ghost.erased t) (p: ptr td)
: STGhost (squash (~(p == null _)))
opened
(pts_to_or_null p v)
(fun _ -> pts_to p v)
(~(p == null _))
(fun _ -> True) =
| rewrite (pts_to_or_null p v) (pts_to p v) | false |
BinomialQueue.fst | BinomialQueue.all_leaf_keys | val all_leaf_keys (l: forest{Cons? l})
: Lemma (requires Cons? l /\ all_leaf l) (ensures permutation (keys l) ms_empty) | val all_leaf_keys (l: forest{Cons? l})
: Lemma (requires Cons? l /\ all_leaf l) (ensures permutation (keys l) ms_empty) | let rec all_leaf_keys (l:forest{Cons? l})
: Lemma
(requires Cons? l /\ all_leaf l)
(ensures permutation (keys l) ms_empty) =
match l with
| [Leaf] -> ()
| Leaf::tl -> all_leaf_keys tl | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 32,
"end_line": 418,
"start_col": 0,
"start_line": 412
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
///
let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right)
/// delete_max finds the maximum key in the forest,
/// deletes it from its tree, and joins the remaining forests
let delete_max q =
match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r)
/// merge is just join with Leaf as the carry
let merge p q =
let l = join 1 p q Leaf in
mk_compact l
/// Towards defining repr
let rec keys_of_tree (t:tree) : ms =
match t with
| Leaf -> ms_empty
| Internal left k right ->
ms_append (keys_of_tree left)
(ms_cons k (keys_of_tree right))
let rec keys (q:forest) : ms =
match q with
| [] -> ms_empty
| hd::tl -> ms_append (keys_of_tree hd) (keys tl)
let repr_t (t:tree) (l:ms) : prop =
permutation (keys_of_tree t) l
let repr_l (q:forest) (s:ms) : prop =
permutation (keys q) s
/// The main repr predicate saying s is a permutation of (keys q)
let repr q s = repr_l q s
let empty_repr _ = ()
/// Correctness of carry and join
let smash_repr (d:pos) (t1 t2:tree) (l1 l2:ms)
: Lemma
(requires
is_pow2heap d t1 /\
is_pow2heap d t2 /\
t1 `repr_t` l1 /\
t2 `repr_t` l2)
(ensures smash d t1 t2 `repr_t` (ms_append l1 l2)) = ()
let rec carry_repr (d:pos) (q:forest) (t:tree) (lq lt:ms)
: Lemma
(requires
is_binomial_queue d q /\
is_pow2heap d t /\
q `repr_l` lq /\
t `repr_t` lt)
(ensures carry d q t `repr_l` ms_append lq lt)
(decreases q) =
match q with
| [] -> ()
| Leaf::_ -> ()
| hd::tl ->
smash_repr d hd t (keys_of_tree hd) (keys_of_tree t);
carry_repr (d + 1) tl (smash d hd t)
(keys tl)
(ms_append (keys_of_tree hd) (keys_of_tree t))
#push-options "--z3rlimit 50 --fuel 1 --ifuel 1"
let rec join_repr (d:pos) (p q:forest) (c:tree)
(lp lq lc:ms)
: Lemma
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c) /\
p `repr_l` lp /\
q `repr_l` lq /\
c `repr_t` lc)
(ensures join d p q c `repr_l` ms_append lp (ms_append lq lc))
(decreases p) =
match p, q, c with
| [], _, Leaf
| _, [], Leaf -> ()
| [], _, _ -> carry_repr d q c lq lc
| _, [], _ -> carry_repr d p c lp lc
| Leaf::tl_p, Leaf::tl_q, _ ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| hd_p::tl_p, Leaf::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, _ ->
smash_repr d hd_q c (keys_of_tree hd_q) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_q c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_q) (keys_of_tree c))
| hd_p::tl_p, Leaf::tl_q, _ ->
smash_repr d hd_p c (keys_of_tree hd_p) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_p c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree c))
| hd_p::tl_p, hd_q::tl_q, c ->
smash_repr d hd_p hd_q (keys_of_tree hd_p) (keys_of_tree hd_q);
join_repr (d + 1) tl_p tl_q (smash d hd_p hd_q)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree hd_q))
#pop-options
/// mk_compact preserves keys | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: BinomialQueue.forest{Cons? l}
-> FStar.Pervasives.Lemma (requires Cons? l /\ BinomialQueue.all_leaf l)
(ensures BinomialQueue.permutation (BinomialQueue.keys l) BinomialQueue.ms_empty) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"BinomialQueue.forest",
"Prims.b2t",
"Prims.uu___is_Cons",
"BinomialQueue.tree",
"Prims.list",
"BinomialQueue.all_leaf_keys",
"Prims.unit",
"Prims.l_and",
"BinomialQueue.all_leaf",
"Prims.squash",
"BinomialQueue.permutation",
"BinomialQueue.keys",
"BinomialQueue.ms_empty",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec all_leaf_keys (l: forest{Cons? l})
: Lemma (requires Cons? l /\ all_leaf l) (ensures permutation (keys l) ms_empty) =
| match l with
| [Leaf] -> ()
| Leaf :: tl -> all_leaf_keys tl | false |
BinomialQueue.fst | BinomialQueue.compact_preserves_keys | val compact_preserves_keys (q: forest)
: Lemma (permutation (keys q) (keys (mk_compact q))) [SMTPat (keys (mk_compact q))] | val compact_preserves_keys (q: forest)
: Lemma (permutation (keys q) (keys (mk_compact q))) [SMTPat (keys (mk_compact q))] | let rec compact_preserves_keys (q:forest)
: Lemma (permutation (keys q) (keys (mk_compact q)))
[SMTPat (keys (mk_compact q))] =
match q with
| [] -> ()
| _ ->
if all_leaf q
then all_leaf_keys q
else compact_preserves_keys (L.tl q) | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 40,
"end_line": 429,
"start_col": 0,
"start_line": 420
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
///
let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right)
/// delete_max finds the maximum key in the forest,
/// deletes it from its tree, and joins the remaining forests
let delete_max q =
match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r)
/// merge is just join with Leaf as the carry
let merge p q =
let l = join 1 p q Leaf in
mk_compact l
/// Towards defining repr
let rec keys_of_tree (t:tree) : ms =
match t with
| Leaf -> ms_empty
| Internal left k right ->
ms_append (keys_of_tree left)
(ms_cons k (keys_of_tree right))
let rec keys (q:forest) : ms =
match q with
| [] -> ms_empty
| hd::tl -> ms_append (keys_of_tree hd) (keys tl)
let repr_t (t:tree) (l:ms) : prop =
permutation (keys_of_tree t) l
let repr_l (q:forest) (s:ms) : prop =
permutation (keys q) s
/// The main repr predicate saying s is a permutation of (keys q)
let repr q s = repr_l q s
let empty_repr _ = ()
/// Correctness of carry and join
let smash_repr (d:pos) (t1 t2:tree) (l1 l2:ms)
: Lemma
(requires
is_pow2heap d t1 /\
is_pow2heap d t2 /\
t1 `repr_t` l1 /\
t2 `repr_t` l2)
(ensures smash d t1 t2 `repr_t` (ms_append l1 l2)) = ()
let rec carry_repr (d:pos) (q:forest) (t:tree) (lq lt:ms)
: Lemma
(requires
is_binomial_queue d q /\
is_pow2heap d t /\
q `repr_l` lq /\
t `repr_t` lt)
(ensures carry d q t `repr_l` ms_append lq lt)
(decreases q) =
match q with
| [] -> ()
| Leaf::_ -> ()
| hd::tl ->
smash_repr d hd t (keys_of_tree hd) (keys_of_tree t);
carry_repr (d + 1) tl (smash d hd t)
(keys tl)
(ms_append (keys_of_tree hd) (keys_of_tree t))
#push-options "--z3rlimit 50 --fuel 1 --ifuel 1"
let rec join_repr (d:pos) (p q:forest) (c:tree)
(lp lq lc:ms)
: Lemma
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c) /\
p `repr_l` lp /\
q `repr_l` lq /\
c `repr_t` lc)
(ensures join d p q c `repr_l` ms_append lp (ms_append lq lc))
(decreases p) =
match p, q, c with
| [], _, Leaf
| _, [], Leaf -> ()
| [], _, _ -> carry_repr d q c lq lc
| _, [], _ -> carry_repr d p c lp lc
| Leaf::tl_p, Leaf::tl_q, _ ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| hd_p::tl_p, Leaf::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, _ ->
smash_repr d hd_q c (keys_of_tree hd_q) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_q c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_q) (keys_of_tree c))
| hd_p::tl_p, Leaf::tl_q, _ ->
smash_repr d hd_p c (keys_of_tree hd_p) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_p c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree c))
| hd_p::tl_p, hd_q::tl_q, c ->
smash_repr d hd_p hd_q (keys_of_tree hd_p) (keys_of_tree hd_q);
join_repr (d + 1) tl_p tl_q (smash d hd_p hd_q)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree hd_q))
#pop-options
/// mk_compact preserves keys
let rec all_leaf_keys (l:forest{Cons? l})
: Lemma
(requires Cons? l /\ all_leaf l)
(ensures permutation (keys l) ms_empty) =
match l with
| [Leaf] -> ()
| Leaf::tl -> all_leaf_keys tl | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | q: BinomialQueue.forest
-> FStar.Pervasives.Lemma
(ensures
BinomialQueue.permutation (BinomialQueue.keys q)
(BinomialQueue.keys (BinomialQueue.mk_compact q)))
[SMTPat (BinomialQueue.keys (BinomialQueue.mk_compact q))] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"BinomialQueue.forest",
"Prims.list",
"BinomialQueue.tree",
"BinomialQueue.all_leaf",
"BinomialQueue.all_leaf_keys",
"Prims.bool",
"BinomialQueue.compact_preserves_keys",
"FStar.List.Tot.Base.tl",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"BinomialQueue.permutation",
"BinomialQueue.keys",
"BinomialQueue.mk_compact",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"BinomialQueue.ms",
"Prims.Nil"
] | [
"recursion"
] | false | false | true | false | false | let rec compact_preserves_keys (q: forest)
: Lemma (permutation (keys q) (keys (mk_compact q))) [SMTPat (keys (mk_compact q))] =
| match q with
| [] -> ()
| _ -> if all_leaf q then all_leaf_keys q else compact_preserves_keys (L.tl q) | false |
Steel.GhostMonotonicHigherReference.fst | Steel.GhostMonotonicHigherReference.extract_pure | val extract_pure (#a #uses #p #f: _) (r: ref a p) (v: a) (h: (history a p))
: SteelGhostT (_: unit{history_val h v f})
uses
(pts_to_body r f v h)
(fun _ -> pts_to_body r f v h) | val extract_pure (#a #uses #p #f: _) (r: ref a p) (v: a) (h: (history a p))
: SteelGhostT (_: unit{history_val h v f})
uses
(pts_to_body r f v h)
(fun _ -> pts_to_body r f v h) | let extract_pure #a #uses #p #f
(r:ref a p)
(v:a)
(h:(history a p))
: SteelGhostT (_:unit{history_val h v f})
uses
(pts_to_body r f v h)
(fun _ -> pts_to_body r f v h)
= elim_pure (history_val h v f);
A.intro_pure (history_val h v f) | {
"file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 36,
"end_line": 84,
"start_col": 0,
"start_line": 75
} | (*
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.GhostMonotonicHigherReference
open FStar.Ghost
open FStar.PCM
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.GhostPCMReference
open Steel.FractionalPermission
open Steel.Preorder
module Preorder = FStar.Preorder
module Q = Steel.Preorder
module M = Steel.Memory
module PR = Steel.GhostPCMReference
module A = Steel.Effect.Atomic
open FStar.Real
#set-options "--ide_id_info_off"
let ref a p = PR.ref (history a p) pcm_history
[@@__reduce__]
let pts_to_body #a #p (r:ref a p) (f:perm) (v:a) (h:history a p) =
PR.pts_to r h `star`
pure (history_val h v f)
let pts_to' (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v: a) =
h_exists (pts_to_body r f v)
let pts_to_sl r f v = hp_of (pts_to' r f v)
let intro_pure #opened #a #p #f
(r:ref a p)
(v:a)
(h:history a p { history_val h v f })
: SteelGhostT unit opened
(PR.pts_to r h)
(fun _ -> pts_to_body r f v h)
= A.intro_pure (history_val h v f)
let intro_pure_full #opened #a #p #f
(r:ref a p)
(v:a)
(h:history a p { history_val h v f })
: SteelGhostT unit opened
(PR.pts_to r h)
(fun _ -> pts_to r f v)
= intro_pure #_ #a #p #f r v h;
intro_exists h (pts_to_body r f v)
let alloc #_ (#a:Type) (p:Preorder.preorder a) (v:a)
= let h = Current [v] full_perm in
assert (compatible pcm_history h h);
let x : ref a p = alloc h in
intro_pure_full x v h;
x | {
"checked_file": "/",
"dependencies": [
"Steel.Preorder.fst.checked",
"Steel.Memory.fsti.checked",
"Steel.GhostPCMReference.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.GhostMonotonicHigherReference.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Real",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Effect.Atomic",
"short_module": "A"
},
{
"abbrev": true,
"full_module": "Steel.GhostPCMReference",
"short_module": "PR"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Steel.Preorder",
"short_module": "Q"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"abbrev": false,
"full_module": "Steel.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.GhostPCMReference",
"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.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"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": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | r: Steel.GhostMonotonicHigherReference.ref a p -> v: a -> h: Steel.Preorder.history a p
-> Steel.Effect.Atomic.SteelGhostT
(_: Prims.unit{Steel.Preorder.history_val h (FStar.Ghost.hide v) f}) | Steel.Effect.Atomic.SteelGhostT | [] | [] | [
"Steel.Memory.inames",
"FStar.Preorder.preorder",
"Steel.FractionalPermission.perm",
"Steel.GhostMonotonicHigherReference.ref",
"Steel.Preorder.history",
"Steel.Effect.Atomic.intro_pure",
"Steel.Preorder.history_val",
"FStar.Ghost.hide",
"Prims.unit",
"Steel.Effect.Atomic.elim_pure",
"Steel.GhostMonotonicHigherReference.pts_to_body",
"Steel.Effect.Common.vprop"
] | [] | false | true | false | false | false | let extract_pure #a #uses #p #f (r: ref a p) (v: a) (h: (history a p))
: SteelGhostT (_: unit{history_val h v f})
uses
(pts_to_body r f v h)
(fun _ -> pts_to_body r f v h) =
| elim_pure (history_val h v f);
A.intro_pure (history_val h v f) | false |
BinomialQueue.fst | BinomialQueue.find_max_emp_repr_r | val find_max_emp_repr_r (l: forest)
: Lemma (requires find_max None l == None) (ensures permutation (keys l) ms_empty) | val find_max_emp_repr_r (l: forest)
: Lemma (requires find_max None l == None) (ensures permutation (keys l) ms_empty) | let rec find_max_emp_repr_r (l:forest)
: Lemma
(requires find_max None l == None)
(ensures permutation (keys l) ms_empty) =
match l with
| [] -> ()
| Leaf::tl -> find_max_emp_repr_r tl
| (Internal _ k _)::tl -> find_max_some_is_some k tl | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 54,
"end_line": 478,
"start_col": 0,
"start_line": 471
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
///
let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right)
/// delete_max finds the maximum key in the forest,
/// deletes it from its tree, and joins the remaining forests
let delete_max q =
match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r)
/// merge is just join with Leaf as the carry
let merge p q =
let l = join 1 p q Leaf in
mk_compact l
/// Towards defining repr
let rec keys_of_tree (t:tree) : ms =
match t with
| Leaf -> ms_empty
| Internal left k right ->
ms_append (keys_of_tree left)
(ms_cons k (keys_of_tree right))
let rec keys (q:forest) : ms =
match q with
| [] -> ms_empty
| hd::tl -> ms_append (keys_of_tree hd) (keys tl)
let repr_t (t:tree) (l:ms) : prop =
permutation (keys_of_tree t) l
let repr_l (q:forest) (s:ms) : prop =
permutation (keys q) s
/// The main repr predicate saying s is a permutation of (keys q)
let repr q s = repr_l q s
let empty_repr _ = ()
/// Correctness of carry and join
let smash_repr (d:pos) (t1 t2:tree) (l1 l2:ms)
: Lemma
(requires
is_pow2heap d t1 /\
is_pow2heap d t2 /\
t1 `repr_t` l1 /\
t2 `repr_t` l2)
(ensures smash d t1 t2 `repr_t` (ms_append l1 l2)) = ()
let rec carry_repr (d:pos) (q:forest) (t:tree) (lq lt:ms)
: Lemma
(requires
is_binomial_queue d q /\
is_pow2heap d t /\
q `repr_l` lq /\
t `repr_t` lt)
(ensures carry d q t `repr_l` ms_append lq lt)
(decreases q) =
match q with
| [] -> ()
| Leaf::_ -> ()
| hd::tl ->
smash_repr d hd t (keys_of_tree hd) (keys_of_tree t);
carry_repr (d + 1) tl (smash d hd t)
(keys tl)
(ms_append (keys_of_tree hd) (keys_of_tree t))
#push-options "--z3rlimit 50 --fuel 1 --ifuel 1"
let rec join_repr (d:pos) (p q:forest) (c:tree)
(lp lq lc:ms)
: Lemma
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c) /\
p `repr_l` lp /\
q `repr_l` lq /\
c `repr_t` lc)
(ensures join d p q c `repr_l` ms_append lp (ms_append lq lc))
(decreases p) =
match p, q, c with
| [], _, Leaf
| _, [], Leaf -> ()
| [], _, _ -> carry_repr d q c lq lc
| _, [], _ -> carry_repr d p c lp lc
| Leaf::tl_p, Leaf::tl_q, _ ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| hd_p::tl_p, Leaf::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, _ ->
smash_repr d hd_q c (keys_of_tree hd_q) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_q c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_q) (keys_of_tree c))
| hd_p::tl_p, Leaf::tl_q, _ ->
smash_repr d hd_p c (keys_of_tree hd_p) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_p c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree c))
| hd_p::tl_p, hd_q::tl_q, c ->
smash_repr d hd_p hd_q (keys_of_tree hd_p) (keys_of_tree hd_q);
join_repr (d + 1) tl_p tl_q (smash d hd_p hd_q)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree hd_q))
#pop-options
/// mk_compact preserves keys
let rec all_leaf_keys (l:forest{Cons? l})
: Lemma
(requires Cons? l /\ all_leaf l)
(ensures permutation (keys l) ms_empty) =
match l with
| [Leaf] -> ()
| Leaf::tl -> all_leaf_keys tl
let rec compact_preserves_keys (q:forest)
: Lemma (permutation (keys q) (keys (mk_compact q)))
[SMTPat (keys (mk_compact q))] =
match q with
| [] -> ()
| _ ->
if all_leaf q
then all_leaf_keys q
else compact_preserves_keys (L.tl q)
/// insert and merge correctness follows from carry and joinx
let insert_repr x q s =
carry_repr 1 q (Internal Leaf x Leaf) s (ms_singleton x)
let merge_repr p q sp sq =
join_repr 1 p q Leaf sp sq ms_empty
/// Towards proof of delete correctness
let rec last_key_in_keys (l:forest)
: Lemma
(requires
Cons? l /\
Internal? (L.last l))
(ensures (let Internal _ k _ = L.last l in
S.subset (S.singleton k) (keys l).ms_elems)) =
match l with
| [Internal _ _ _] -> ()
| _::tl -> last_key_in_keys tl
let rec find_max_some_is_some (k:key_t) (l:forest)
: Lemma (ensures Some? (find_max (Some k) l) /\
k <= Some?.v (find_max (Some k) l))
(decreases l) =
match l with
| [] -> ()
| Leaf::tl -> find_max_some_is_some k tl
| (Internal _ k' _)::tl ->
let k = if k < k' then k' else k in
find_max_some_is_some k tl
let find_max_emp_repr_l (l:priq)
: Lemma
(requires l `repr_l` ms_empty)
(ensures find_max None l == None) =
match l with
| [] -> ()
| _ -> last_key_in_keys l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: BinomialQueue.forest
-> FStar.Pervasives.Lemma
(requires
BinomialQueue.find_max FStar.Pervasives.Native.None l == FStar.Pervasives.Native.None)
(ensures BinomialQueue.permutation (BinomialQueue.keys l) BinomialQueue.ms_empty) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"BinomialQueue.forest",
"Prims.list",
"BinomialQueue.tree",
"BinomialQueue.find_max_emp_repr_r",
"BinomialQueue.key_t",
"BinomialQueue.find_max_some_is_some",
"Prims.unit",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"BinomialQueue.find_max",
"FStar.Pervasives.Native.None",
"Prims.squash",
"BinomialQueue.permutation",
"BinomialQueue.keys",
"BinomialQueue.ms_empty",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec find_max_emp_repr_r (l: forest)
: Lemma (requires find_max None l == None) (ensures permutation (keys l) ms_empty) =
| match l with
| [] -> ()
| Leaf :: tl -> find_max_emp_repr_r tl
| Internal _ k _ :: tl -> find_max_some_is_some k tl | false |
BinomialQueue.fst | BinomialQueue.find_max_emp_repr_l | val find_max_emp_repr_l (l: priq)
: Lemma (requires l `repr_l` ms_empty) (ensures find_max None l == None) | val find_max_emp_repr_l (l: priq)
: Lemma (requires l `repr_l` ms_empty) (ensures find_max None l == None) | let find_max_emp_repr_l (l:priq)
: Lemma
(requires l `repr_l` ms_empty)
(ensures find_max None l == None) =
match l with
| [] -> ()
| _ -> last_key_in_keys l | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"end_line": 469,
"start_col": 0,
"start_line": 463
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
///
let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right)
/// delete_max finds the maximum key in the forest,
/// deletes it from its tree, and joins the remaining forests
let delete_max q =
match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r)
/// merge is just join with Leaf as the carry
let merge p q =
let l = join 1 p q Leaf in
mk_compact l
/// Towards defining repr
let rec keys_of_tree (t:tree) : ms =
match t with
| Leaf -> ms_empty
| Internal left k right ->
ms_append (keys_of_tree left)
(ms_cons k (keys_of_tree right))
let rec keys (q:forest) : ms =
match q with
| [] -> ms_empty
| hd::tl -> ms_append (keys_of_tree hd) (keys tl)
let repr_t (t:tree) (l:ms) : prop =
permutation (keys_of_tree t) l
let repr_l (q:forest) (s:ms) : prop =
permutation (keys q) s
/// The main repr predicate saying s is a permutation of (keys q)
let repr q s = repr_l q s
let empty_repr _ = ()
/// Correctness of carry and join
let smash_repr (d:pos) (t1 t2:tree) (l1 l2:ms)
: Lemma
(requires
is_pow2heap d t1 /\
is_pow2heap d t2 /\
t1 `repr_t` l1 /\
t2 `repr_t` l2)
(ensures smash d t1 t2 `repr_t` (ms_append l1 l2)) = ()
let rec carry_repr (d:pos) (q:forest) (t:tree) (lq lt:ms)
: Lemma
(requires
is_binomial_queue d q /\
is_pow2heap d t /\
q `repr_l` lq /\
t `repr_t` lt)
(ensures carry d q t `repr_l` ms_append lq lt)
(decreases q) =
match q with
| [] -> ()
| Leaf::_ -> ()
| hd::tl ->
smash_repr d hd t (keys_of_tree hd) (keys_of_tree t);
carry_repr (d + 1) tl (smash d hd t)
(keys tl)
(ms_append (keys_of_tree hd) (keys_of_tree t))
#push-options "--z3rlimit 50 --fuel 1 --ifuel 1"
let rec join_repr (d:pos) (p q:forest) (c:tree)
(lp lq lc:ms)
: Lemma
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c) /\
p `repr_l` lp /\
q `repr_l` lq /\
c `repr_t` lc)
(ensures join d p q c `repr_l` ms_append lp (ms_append lq lc))
(decreases p) =
match p, q, c with
| [], _, Leaf
| _, [], Leaf -> ()
| [], _, _ -> carry_repr d q c lq lc
| _, [], _ -> carry_repr d p c lp lc
| Leaf::tl_p, Leaf::tl_q, _ ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| hd_p::tl_p, Leaf::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, _ ->
smash_repr d hd_q c (keys_of_tree hd_q) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_q c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_q) (keys_of_tree c))
| hd_p::tl_p, Leaf::tl_q, _ ->
smash_repr d hd_p c (keys_of_tree hd_p) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_p c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree c))
| hd_p::tl_p, hd_q::tl_q, c ->
smash_repr d hd_p hd_q (keys_of_tree hd_p) (keys_of_tree hd_q);
join_repr (d + 1) tl_p tl_q (smash d hd_p hd_q)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree hd_q))
#pop-options
/// mk_compact preserves keys
let rec all_leaf_keys (l:forest{Cons? l})
: Lemma
(requires Cons? l /\ all_leaf l)
(ensures permutation (keys l) ms_empty) =
match l with
| [Leaf] -> ()
| Leaf::tl -> all_leaf_keys tl
let rec compact_preserves_keys (q:forest)
: Lemma (permutation (keys q) (keys (mk_compact q)))
[SMTPat (keys (mk_compact q))] =
match q with
| [] -> ()
| _ ->
if all_leaf q
then all_leaf_keys q
else compact_preserves_keys (L.tl q)
/// insert and merge correctness follows from carry and joinx
let insert_repr x q s =
carry_repr 1 q (Internal Leaf x Leaf) s (ms_singleton x)
let merge_repr p q sp sq =
join_repr 1 p q Leaf sp sq ms_empty
/// Towards proof of delete correctness
let rec last_key_in_keys (l:forest)
: Lemma
(requires
Cons? l /\
Internal? (L.last l))
(ensures (let Internal _ k _ = L.last l in
S.subset (S.singleton k) (keys l).ms_elems)) =
match l with
| [Internal _ _ _] -> ()
| _::tl -> last_key_in_keys tl
let rec find_max_some_is_some (k:key_t) (l:forest)
: Lemma (ensures Some? (find_max (Some k) l) /\
k <= Some?.v (find_max (Some k) l))
(decreases l) =
match l with
| [] -> ()
| Leaf::tl -> find_max_some_is_some k tl
| (Internal _ k' _)::tl ->
let k = if k < k' then k' else k in
find_max_some_is_some k tl | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: BinomialQueue.priq
-> FStar.Pervasives.Lemma (requires BinomialQueue.repr_l l BinomialQueue.ms_empty)
(ensures BinomialQueue.find_max FStar.Pervasives.Native.None l == FStar.Pervasives.Native.None
) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"BinomialQueue.priq",
"Prims.list",
"BinomialQueue.tree",
"BinomialQueue.last_key_in_keys",
"Prims.unit",
"BinomialQueue.repr_l",
"BinomialQueue.ms_empty",
"Prims.squash",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"BinomialQueue.key_t",
"BinomialQueue.find_max",
"FStar.Pervasives.Native.None",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let find_max_emp_repr_l (l: priq)
: Lemma (requires l `repr_l` ms_empty) (ensures find_max None l == None) =
| match l with
| [] -> ()
| _ -> last_key_in_keys l | false |
BinomialQueue.fst | BinomialQueue.find_max_some_is_some | val find_max_some_is_some (k: key_t) (l: forest)
: Lemma (ensures Some? (find_max (Some k) l) /\ k <= Some?.v (find_max (Some k) l))
(decreases l) | val find_max_some_is_some (k: key_t) (l: forest)
: Lemma (ensures Some? (find_max (Some k) l) /\ k <= Some?.v (find_max (Some k) l))
(decreases l) | let rec find_max_some_is_some (k:key_t) (l:forest)
: Lemma (ensures Some? (find_max (Some k) l) /\
k <= Some?.v (find_max (Some k) l))
(decreases l) =
match l with
| [] -> ()
| Leaf::tl -> find_max_some_is_some k tl
| (Internal _ k' _)::tl ->
let k = if k < k' then k' else k in
find_max_some_is_some k tl | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 30,
"end_line": 461,
"start_col": 0,
"start_line": 452
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
///
let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right)
/// delete_max finds the maximum key in the forest,
/// deletes it from its tree, and joins the remaining forests
let delete_max q =
match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r)
/// merge is just join with Leaf as the carry
let merge p q =
let l = join 1 p q Leaf in
mk_compact l
/// Towards defining repr
let rec keys_of_tree (t:tree) : ms =
match t with
| Leaf -> ms_empty
| Internal left k right ->
ms_append (keys_of_tree left)
(ms_cons k (keys_of_tree right))
let rec keys (q:forest) : ms =
match q with
| [] -> ms_empty
| hd::tl -> ms_append (keys_of_tree hd) (keys tl)
let repr_t (t:tree) (l:ms) : prop =
permutation (keys_of_tree t) l
let repr_l (q:forest) (s:ms) : prop =
permutation (keys q) s
/// The main repr predicate saying s is a permutation of (keys q)
let repr q s = repr_l q s
let empty_repr _ = ()
/// Correctness of carry and join
let smash_repr (d:pos) (t1 t2:tree) (l1 l2:ms)
: Lemma
(requires
is_pow2heap d t1 /\
is_pow2heap d t2 /\
t1 `repr_t` l1 /\
t2 `repr_t` l2)
(ensures smash d t1 t2 `repr_t` (ms_append l1 l2)) = ()
let rec carry_repr (d:pos) (q:forest) (t:tree) (lq lt:ms)
: Lemma
(requires
is_binomial_queue d q /\
is_pow2heap d t /\
q `repr_l` lq /\
t `repr_t` lt)
(ensures carry d q t `repr_l` ms_append lq lt)
(decreases q) =
match q with
| [] -> ()
| Leaf::_ -> ()
| hd::tl ->
smash_repr d hd t (keys_of_tree hd) (keys_of_tree t);
carry_repr (d + 1) tl (smash d hd t)
(keys tl)
(ms_append (keys_of_tree hd) (keys_of_tree t))
#push-options "--z3rlimit 50 --fuel 1 --ifuel 1"
let rec join_repr (d:pos) (p q:forest) (c:tree)
(lp lq lc:ms)
: Lemma
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c) /\
p `repr_l` lp /\
q `repr_l` lq /\
c `repr_t` lc)
(ensures join d p q c `repr_l` ms_append lp (ms_append lq lc))
(decreases p) =
match p, q, c with
| [], _, Leaf
| _, [], Leaf -> ()
| [], _, _ -> carry_repr d q c lq lc
| _, [], _ -> carry_repr d p c lp lc
| Leaf::tl_p, Leaf::tl_q, _ ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| hd_p::tl_p, Leaf::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, _ ->
smash_repr d hd_q c (keys_of_tree hd_q) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_q c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_q) (keys_of_tree c))
| hd_p::tl_p, Leaf::tl_q, _ ->
smash_repr d hd_p c (keys_of_tree hd_p) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_p c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree c))
| hd_p::tl_p, hd_q::tl_q, c ->
smash_repr d hd_p hd_q (keys_of_tree hd_p) (keys_of_tree hd_q);
join_repr (d + 1) tl_p tl_q (smash d hd_p hd_q)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree hd_q))
#pop-options
/// mk_compact preserves keys
let rec all_leaf_keys (l:forest{Cons? l})
: Lemma
(requires Cons? l /\ all_leaf l)
(ensures permutation (keys l) ms_empty) =
match l with
| [Leaf] -> ()
| Leaf::tl -> all_leaf_keys tl
let rec compact_preserves_keys (q:forest)
: Lemma (permutation (keys q) (keys (mk_compact q)))
[SMTPat (keys (mk_compact q))] =
match q with
| [] -> ()
| _ ->
if all_leaf q
then all_leaf_keys q
else compact_preserves_keys (L.tl q)
/// insert and merge correctness follows from carry and joinx
let insert_repr x q s =
carry_repr 1 q (Internal Leaf x Leaf) s (ms_singleton x)
let merge_repr p q sp sq =
join_repr 1 p q Leaf sp sq ms_empty
/// Towards proof of delete correctness
let rec last_key_in_keys (l:forest)
: Lemma
(requires
Cons? l /\
Internal? (L.last l))
(ensures (let Internal _ k _ = L.last l in
S.subset (S.singleton k) (keys l).ms_elems)) =
match l with
| [Internal _ _ _] -> ()
| _::tl -> last_key_in_keys tl | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: BinomialQueue.key_t -> l: BinomialQueue.forest
-> FStar.Pervasives.Lemma
(ensures
Some? (BinomialQueue.find_max (FStar.Pervasives.Native.Some k) l) /\
k <= Some?.v (BinomialQueue.find_max (FStar.Pervasives.Native.Some k) l)) (decreases l) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"BinomialQueue.key_t",
"BinomialQueue.forest",
"Prims.list",
"BinomialQueue.tree",
"BinomialQueue.find_max_some_is_some",
"Prims.op_LessThan",
"Prims.bool",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_and",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"BinomialQueue.find_max",
"FStar.Pervasives.Native.Some",
"Prims.op_LessThanOrEqual",
"FStar.Pervasives.Native.__proj__Some__item__v",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec find_max_some_is_some (k: key_t) (l: forest)
: Lemma (ensures Some? (find_max (Some k) l) /\ k <= Some?.v (find_max (Some k) l))
(decreases l) =
| match l with
| [] -> ()
| Leaf :: tl -> find_max_some_is_some k tl
| Internal _ k' _ :: tl ->
let k = if k < k' then k' else k in
find_max_some_is_some k tl | false |
BinomialQueue.fst | BinomialQueue.tree_root_is_max | val tree_root_is_max (d: pos) (t: tree)
: Lemma (requires is_pow2heap d t)
(ensures
(let Internal left k Leaf = t in
max k (keys_of_tree left).ms_elems)) | val tree_root_is_max (d: pos) (t: tree)
: Lemma (requires is_pow2heap d t)
(ensures
(let Internal left k Leaf = t in
max k (keys_of_tree left).ms_elems)) | let tree_root_is_max (d:pos) (t:tree)
: Lemma
(requires is_pow2heap d t)
(ensures
(let Internal left k Leaf = t in
max k (keys_of_tree left).ms_elems)) =
let Internal left k Leaf = t in
tree_root_is_max_aux (d - 1) k left | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 37,
"end_line": 555,
"start_col": 0,
"start_line": 548
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
///
let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right)
/// delete_max finds the maximum key in the forest,
/// deletes it from its tree, and joins the remaining forests
let delete_max q =
match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r)
/// merge is just join with Leaf as the carry
let merge p q =
let l = join 1 p q Leaf in
mk_compact l
/// Towards defining repr
let rec keys_of_tree (t:tree) : ms =
match t with
| Leaf -> ms_empty
| Internal left k right ->
ms_append (keys_of_tree left)
(ms_cons k (keys_of_tree right))
let rec keys (q:forest) : ms =
match q with
| [] -> ms_empty
| hd::tl -> ms_append (keys_of_tree hd) (keys tl)
let repr_t (t:tree) (l:ms) : prop =
permutation (keys_of_tree t) l
let repr_l (q:forest) (s:ms) : prop =
permutation (keys q) s
/// The main repr predicate saying s is a permutation of (keys q)
let repr q s = repr_l q s
let empty_repr _ = ()
/// Correctness of carry and join
let smash_repr (d:pos) (t1 t2:tree) (l1 l2:ms)
: Lemma
(requires
is_pow2heap d t1 /\
is_pow2heap d t2 /\
t1 `repr_t` l1 /\
t2 `repr_t` l2)
(ensures smash d t1 t2 `repr_t` (ms_append l1 l2)) = ()
let rec carry_repr (d:pos) (q:forest) (t:tree) (lq lt:ms)
: Lemma
(requires
is_binomial_queue d q /\
is_pow2heap d t /\
q `repr_l` lq /\
t `repr_t` lt)
(ensures carry d q t `repr_l` ms_append lq lt)
(decreases q) =
match q with
| [] -> ()
| Leaf::_ -> ()
| hd::tl ->
smash_repr d hd t (keys_of_tree hd) (keys_of_tree t);
carry_repr (d + 1) tl (smash d hd t)
(keys tl)
(ms_append (keys_of_tree hd) (keys_of_tree t))
#push-options "--z3rlimit 50 --fuel 1 --ifuel 1"
let rec join_repr (d:pos) (p q:forest) (c:tree)
(lp lq lc:ms)
: Lemma
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c) /\
p `repr_l` lp /\
q `repr_l` lq /\
c `repr_t` lc)
(ensures join d p q c `repr_l` ms_append lp (ms_append lq lc))
(decreases p) =
match p, q, c with
| [], _, Leaf
| _, [], Leaf -> ()
| [], _, _ -> carry_repr d q c lq lc
| _, [], _ -> carry_repr d p c lp lc
| Leaf::tl_p, Leaf::tl_q, _ ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| hd_p::tl_p, Leaf::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, _ ->
smash_repr d hd_q c (keys_of_tree hd_q) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_q c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_q) (keys_of_tree c))
| hd_p::tl_p, Leaf::tl_q, _ ->
smash_repr d hd_p c (keys_of_tree hd_p) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_p c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree c))
| hd_p::tl_p, hd_q::tl_q, c ->
smash_repr d hd_p hd_q (keys_of_tree hd_p) (keys_of_tree hd_q);
join_repr (d + 1) tl_p tl_q (smash d hd_p hd_q)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree hd_q))
#pop-options
/// mk_compact preserves keys
let rec all_leaf_keys (l:forest{Cons? l})
: Lemma
(requires Cons? l /\ all_leaf l)
(ensures permutation (keys l) ms_empty) =
match l with
| [Leaf] -> ()
| Leaf::tl -> all_leaf_keys tl
let rec compact_preserves_keys (q:forest)
: Lemma (permutation (keys q) (keys (mk_compact q)))
[SMTPat (keys (mk_compact q))] =
match q with
| [] -> ()
| _ ->
if all_leaf q
then all_leaf_keys q
else compact_preserves_keys (L.tl q)
/// insert and merge correctness follows from carry and joinx
let insert_repr x q s =
carry_repr 1 q (Internal Leaf x Leaf) s (ms_singleton x)
let merge_repr p q sp sq =
join_repr 1 p q Leaf sp sq ms_empty
/// Towards proof of delete correctness
let rec last_key_in_keys (l:forest)
: Lemma
(requires
Cons? l /\
Internal? (L.last l))
(ensures (let Internal _ k _ = L.last l in
S.subset (S.singleton k) (keys l).ms_elems)) =
match l with
| [Internal _ _ _] -> ()
| _::tl -> last_key_in_keys tl
let rec find_max_some_is_some (k:key_t) (l:forest)
: Lemma (ensures Some? (find_max (Some k) l) /\
k <= Some?.v (find_max (Some k) l))
(decreases l) =
match l with
| [] -> ()
| Leaf::tl -> find_max_some_is_some k tl
| (Internal _ k' _)::tl ->
let k = if k < k' then k' else k in
find_max_some_is_some k tl
let find_max_emp_repr_l (l:priq)
: Lemma
(requires l `repr_l` ms_empty)
(ensures find_max None l == None) =
match l with
| [] -> ()
| _ -> last_key_in_keys l
let rec find_max_emp_repr_r (l:forest)
: Lemma
(requires find_max None l == None)
(ensures permutation (keys l) ms_empty) =
match l with
| [] -> ()
| Leaf::tl -> find_max_emp_repr_r tl
| (Internal _ k _)::tl -> find_max_some_is_some k tl
#push-options "--warn_error -271"
let delete_max_none_repr p =
let delete_max_none_repr_l (l:priq)
: Lemma
(requires l `repr` ms_empty)
(ensures delete_max l == None)
[SMTPat ()] = find_max_emp_repr_l l in
let delete_max_none_repr_r (l:priq)
: Lemma
(requires delete_max l == None)
(ensures l `repr` ms_empty)
[SMTPat ()] = find_max_emp_repr_r l in
()
#pop-options
let rec keys_append (l1 l2:forest) (ms1 ms2:ms)
: Lemma (requires l1 `repr_l` ms1 /\ l2 `repr_l` ms2)
(ensures (L.append l1 l2) `repr_l` (ms_append ms1 ms2)) =
match l1 with
| [] -> ()
| _::tl -> keys_append tl l2 (keys tl) ms2
let rec unzip_repr (d:nat) (upper_bound:key_t) (t:tree) (lt:ms)
: Lemma
(requires
pow2heap_pred d upper_bound t /\
permutation (keys_of_tree t) lt)
(ensures permutation lt (keys (unzip d upper_bound t)))
(decreases t) =
match t with
| Leaf -> ()
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
unzip_repr (d - 1) upper_bound right (keys_of_tree right);
keys_append q [Internal left k Leaf]
(keys_of_tree right) (ms_append (keys_of_tree left)
(ms_append (ms_singleton k)
ms_empty))
let heap_delete_max_repr (d:pos) (t:tree) (lt:ms)
: Lemma
(requires is_pow2heap d t /\ t `repr_t` lt)
(ensures (
let Internal left k Leaf = t in
permutation lt (ms_append (ms_singleton k)
(keys (heap_delete_max d t))))) =
let Internal left k Leaf = t in
unzip_repr (d - 1) k left (keys_of_tree left)
let max (k:key_t) (s:S.set key_t) =
forall (x:key_t). Set.mem x s ==> x <= k
let rec tree_root_is_max_aux (d:nat) (upper_bound:key_t) (t:tree)
: Lemma
(requires pow2heap_pred d upper_bound t)
(ensures max upper_bound (keys_of_tree t).ms_elems)
(decreases t) =
match t with
| Leaf -> ()
| Internal left k right ->
tree_root_is_max_aux (d - 1) k left;
tree_root_is_max_aux (d - 1) upper_bound right | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: Prims.pos -> t: BinomialQueue.tree
-> FStar.Pervasives.Lemma (requires BinomialQueue.is_pow2heap d t)
(ensures
(let _ = t in
(let BinomialQueue.Internal left k BinomialQueue.Leaf = _ in
BinomialQueue.max k (Mkms?.ms_elems (BinomialQueue.keys_of_tree left)))
<:
Type0)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.pos",
"BinomialQueue.tree",
"BinomialQueue.key_t",
"BinomialQueue.tree_root_is_max_aux",
"Prims.op_Subtraction",
"Prims.unit",
"BinomialQueue.is_pow2heap",
"Prims.squash",
"BinomialQueue.max",
"BinomialQueue.__proj__Mkms__item__ms_elems",
"BinomialQueue.keys_of_tree",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let tree_root_is_max (d: pos) (t: tree)
: Lemma (requires is_pow2heap d t)
(ensures
(let Internal left k Leaf = t in
max k (keys_of_tree left).ms_elems)) =
| let Internal left k Leaf = t in
tree_root_is_max_aux (d - 1) k left | false |
BinomialQueue.fst | BinomialQueue.max | val max : k: BinomialQueue.key_t -> s: FStar.Set.set BinomialQueue.key_t -> Prims.logical | let max (k:key_t) (s:S.set key_t) =
forall (x:key_t). Set.mem x s ==> x <= k | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 42,
"end_line": 534,
"start_col": 0,
"start_line": 533
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
///
let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right)
/// delete_max finds the maximum key in the forest,
/// deletes it from its tree, and joins the remaining forests
let delete_max q =
match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r)
/// merge is just join with Leaf as the carry
let merge p q =
let l = join 1 p q Leaf in
mk_compact l
/// Towards defining repr
let rec keys_of_tree (t:tree) : ms =
match t with
| Leaf -> ms_empty
| Internal left k right ->
ms_append (keys_of_tree left)
(ms_cons k (keys_of_tree right))
let rec keys (q:forest) : ms =
match q with
| [] -> ms_empty
| hd::tl -> ms_append (keys_of_tree hd) (keys tl)
let repr_t (t:tree) (l:ms) : prop =
permutation (keys_of_tree t) l
let repr_l (q:forest) (s:ms) : prop =
permutation (keys q) s
/// The main repr predicate saying s is a permutation of (keys q)
let repr q s = repr_l q s
let empty_repr _ = ()
/// Correctness of carry and join
let smash_repr (d:pos) (t1 t2:tree) (l1 l2:ms)
: Lemma
(requires
is_pow2heap d t1 /\
is_pow2heap d t2 /\
t1 `repr_t` l1 /\
t2 `repr_t` l2)
(ensures smash d t1 t2 `repr_t` (ms_append l1 l2)) = ()
let rec carry_repr (d:pos) (q:forest) (t:tree) (lq lt:ms)
: Lemma
(requires
is_binomial_queue d q /\
is_pow2heap d t /\
q `repr_l` lq /\
t `repr_t` lt)
(ensures carry d q t `repr_l` ms_append lq lt)
(decreases q) =
match q with
| [] -> ()
| Leaf::_ -> ()
| hd::tl ->
smash_repr d hd t (keys_of_tree hd) (keys_of_tree t);
carry_repr (d + 1) tl (smash d hd t)
(keys tl)
(ms_append (keys_of_tree hd) (keys_of_tree t))
#push-options "--z3rlimit 50 --fuel 1 --ifuel 1"
let rec join_repr (d:pos) (p q:forest) (c:tree)
(lp lq lc:ms)
: Lemma
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c) /\
p `repr_l` lp /\
q `repr_l` lq /\
c `repr_t` lc)
(ensures join d p q c `repr_l` ms_append lp (ms_append lq lc))
(decreases p) =
match p, q, c with
| [], _, Leaf
| _, [], Leaf -> ()
| [], _, _ -> carry_repr d q c lq lc
| _, [], _ -> carry_repr d p c lp lc
| Leaf::tl_p, Leaf::tl_q, _ ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| hd_p::tl_p, Leaf::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, _ ->
smash_repr d hd_q c (keys_of_tree hd_q) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_q c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_q) (keys_of_tree c))
| hd_p::tl_p, Leaf::tl_q, _ ->
smash_repr d hd_p c (keys_of_tree hd_p) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_p c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree c))
| hd_p::tl_p, hd_q::tl_q, c ->
smash_repr d hd_p hd_q (keys_of_tree hd_p) (keys_of_tree hd_q);
join_repr (d + 1) tl_p tl_q (smash d hd_p hd_q)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree hd_q))
#pop-options
/// mk_compact preserves keys
let rec all_leaf_keys (l:forest{Cons? l})
: Lemma
(requires Cons? l /\ all_leaf l)
(ensures permutation (keys l) ms_empty) =
match l with
| [Leaf] -> ()
| Leaf::tl -> all_leaf_keys tl
let rec compact_preserves_keys (q:forest)
: Lemma (permutation (keys q) (keys (mk_compact q)))
[SMTPat (keys (mk_compact q))] =
match q with
| [] -> ()
| _ ->
if all_leaf q
then all_leaf_keys q
else compact_preserves_keys (L.tl q)
/// insert and merge correctness follows from carry and joinx
let insert_repr x q s =
carry_repr 1 q (Internal Leaf x Leaf) s (ms_singleton x)
let merge_repr p q sp sq =
join_repr 1 p q Leaf sp sq ms_empty
/// Towards proof of delete correctness
let rec last_key_in_keys (l:forest)
: Lemma
(requires
Cons? l /\
Internal? (L.last l))
(ensures (let Internal _ k _ = L.last l in
S.subset (S.singleton k) (keys l).ms_elems)) =
match l with
| [Internal _ _ _] -> ()
| _::tl -> last_key_in_keys tl
let rec find_max_some_is_some (k:key_t) (l:forest)
: Lemma (ensures Some? (find_max (Some k) l) /\
k <= Some?.v (find_max (Some k) l))
(decreases l) =
match l with
| [] -> ()
| Leaf::tl -> find_max_some_is_some k tl
| (Internal _ k' _)::tl ->
let k = if k < k' then k' else k in
find_max_some_is_some k tl
let find_max_emp_repr_l (l:priq)
: Lemma
(requires l `repr_l` ms_empty)
(ensures find_max None l == None) =
match l with
| [] -> ()
| _ -> last_key_in_keys l
let rec find_max_emp_repr_r (l:forest)
: Lemma
(requires find_max None l == None)
(ensures permutation (keys l) ms_empty) =
match l with
| [] -> ()
| Leaf::tl -> find_max_emp_repr_r tl
| (Internal _ k _)::tl -> find_max_some_is_some k tl
#push-options "--warn_error -271"
let delete_max_none_repr p =
let delete_max_none_repr_l (l:priq)
: Lemma
(requires l `repr` ms_empty)
(ensures delete_max l == None)
[SMTPat ()] = find_max_emp_repr_l l in
let delete_max_none_repr_r (l:priq)
: Lemma
(requires delete_max l == None)
(ensures l `repr` ms_empty)
[SMTPat ()] = find_max_emp_repr_r l in
()
#pop-options
let rec keys_append (l1 l2:forest) (ms1 ms2:ms)
: Lemma (requires l1 `repr_l` ms1 /\ l2 `repr_l` ms2)
(ensures (L.append l1 l2) `repr_l` (ms_append ms1 ms2)) =
match l1 with
| [] -> ()
| _::tl -> keys_append tl l2 (keys tl) ms2
let rec unzip_repr (d:nat) (upper_bound:key_t) (t:tree) (lt:ms)
: Lemma
(requires
pow2heap_pred d upper_bound t /\
permutation (keys_of_tree t) lt)
(ensures permutation lt (keys (unzip d upper_bound t)))
(decreases t) =
match t with
| Leaf -> ()
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
unzip_repr (d - 1) upper_bound right (keys_of_tree right);
keys_append q [Internal left k Leaf]
(keys_of_tree right) (ms_append (keys_of_tree left)
(ms_append (ms_singleton k)
ms_empty))
let heap_delete_max_repr (d:pos) (t:tree) (lt:ms)
: Lemma
(requires is_pow2heap d t /\ t `repr_t` lt)
(ensures (
let Internal left k Leaf = t in
permutation lt (ms_append (ms_singleton k)
(keys (heap_delete_max d t))))) =
let Internal left k Leaf = t in
unzip_repr (d - 1) k left (keys_of_tree left) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: BinomialQueue.key_t -> s: FStar.Set.set BinomialQueue.key_t -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"BinomialQueue.key_t",
"FStar.Set.set",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.b2t",
"FStar.Set.mem",
"Prims.op_LessThanOrEqual",
"Prims.logical"
] | [] | false | false | false | true | true | let max (k: key_t) (s: S.set key_t) =
| forall (x: key_t). Set.mem x s ==> x <= k | false |
|
BinomialQueue.fst | BinomialQueue.insert_repr | val insert_repr (x:key_t) (q:priq) (s:ms)
: Lemma (requires q `repr` s)
(ensures insert x q `repr` (ms_cons x s)) | val insert_repr (x:key_t) (q:priq) (s:ms)
: Lemma (requires q `repr` s)
(ensures insert x q `repr` (ms_cons x s)) | let insert_repr x q s =
carry_repr 1 q (Internal Leaf x Leaf) s (ms_singleton x) | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 58,
"end_line": 434,
"start_col": 0,
"start_line": 433
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
///
let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right)
/// delete_max finds the maximum key in the forest,
/// deletes it from its tree, and joins the remaining forests
let delete_max q =
match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r)
/// merge is just join with Leaf as the carry
let merge p q =
let l = join 1 p q Leaf in
mk_compact l
/// Towards defining repr
let rec keys_of_tree (t:tree) : ms =
match t with
| Leaf -> ms_empty
| Internal left k right ->
ms_append (keys_of_tree left)
(ms_cons k (keys_of_tree right))
let rec keys (q:forest) : ms =
match q with
| [] -> ms_empty
| hd::tl -> ms_append (keys_of_tree hd) (keys tl)
let repr_t (t:tree) (l:ms) : prop =
permutation (keys_of_tree t) l
let repr_l (q:forest) (s:ms) : prop =
permutation (keys q) s
/// The main repr predicate saying s is a permutation of (keys q)
let repr q s = repr_l q s
let empty_repr _ = ()
/// Correctness of carry and join
let smash_repr (d:pos) (t1 t2:tree) (l1 l2:ms)
: Lemma
(requires
is_pow2heap d t1 /\
is_pow2heap d t2 /\
t1 `repr_t` l1 /\
t2 `repr_t` l2)
(ensures smash d t1 t2 `repr_t` (ms_append l1 l2)) = ()
let rec carry_repr (d:pos) (q:forest) (t:tree) (lq lt:ms)
: Lemma
(requires
is_binomial_queue d q /\
is_pow2heap d t /\
q `repr_l` lq /\
t `repr_t` lt)
(ensures carry d q t `repr_l` ms_append lq lt)
(decreases q) =
match q with
| [] -> ()
| Leaf::_ -> ()
| hd::tl ->
smash_repr d hd t (keys_of_tree hd) (keys_of_tree t);
carry_repr (d + 1) tl (smash d hd t)
(keys tl)
(ms_append (keys_of_tree hd) (keys_of_tree t))
#push-options "--z3rlimit 50 --fuel 1 --ifuel 1"
let rec join_repr (d:pos) (p q:forest) (c:tree)
(lp lq lc:ms)
: Lemma
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c) /\
p `repr_l` lp /\
q `repr_l` lq /\
c `repr_t` lc)
(ensures join d p q c `repr_l` ms_append lp (ms_append lq lc))
(decreases p) =
match p, q, c with
| [], _, Leaf
| _, [], Leaf -> ()
| [], _, _ -> carry_repr d q c lq lc
| _, [], _ -> carry_repr d p c lp lc
| Leaf::tl_p, Leaf::tl_q, _ ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| hd_p::tl_p, Leaf::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, _ ->
smash_repr d hd_q c (keys_of_tree hd_q) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_q c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_q) (keys_of_tree c))
| hd_p::tl_p, Leaf::tl_q, _ ->
smash_repr d hd_p c (keys_of_tree hd_p) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_p c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree c))
| hd_p::tl_p, hd_q::tl_q, c ->
smash_repr d hd_p hd_q (keys_of_tree hd_p) (keys_of_tree hd_q);
join_repr (d + 1) tl_p tl_q (smash d hd_p hd_q)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree hd_q))
#pop-options
/// mk_compact preserves keys
let rec all_leaf_keys (l:forest{Cons? l})
: Lemma
(requires Cons? l /\ all_leaf l)
(ensures permutation (keys l) ms_empty) =
match l with
| [Leaf] -> ()
| Leaf::tl -> all_leaf_keys tl
let rec compact_preserves_keys (q:forest)
: Lemma (permutation (keys q) (keys (mk_compact q)))
[SMTPat (keys (mk_compact q))] =
match q with
| [] -> ()
| _ ->
if all_leaf q
then all_leaf_keys q
else compact_preserves_keys (L.tl q)
/// insert and merge correctness follows from carry and joinx | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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: BinomialQueue.key_t -> q: BinomialQueue.priq -> s: BinomialQueue.ms
-> FStar.Pervasives.Lemma (requires BinomialQueue.repr q s)
(ensures BinomialQueue.repr (BinomialQueue.insert x q) (BinomialQueue.ms_cons x s)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"BinomialQueue.key_t",
"BinomialQueue.priq",
"BinomialQueue.ms",
"BinomialQueue.carry_repr",
"BinomialQueue.Internal",
"BinomialQueue.Leaf",
"BinomialQueue.ms_singleton",
"Prims.unit"
] | [] | true | false | true | false | false | let insert_repr x q s =
| carry_repr 1 q (Internal Leaf x Leaf) s (ms_singleton x) | false |
BinomialQueue.fst | BinomialQueue.find_max_mem_keys | val find_max_mem_keys (kopt: option key_t) (q: forest)
: Lemma
(ensures
find_max kopt q == kopt \/
(let kopt = find_max kopt q in
Some? kopt /\ S.mem (Some?.v kopt) (keys q).ms_elems)) (decreases q) | val find_max_mem_keys (kopt: option key_t) (q: forest)
: Lemma
(ensures
find_max kopt q == kopt \/
(let kopt = find_max kopt q in
Some? kopt /\ S.mem (Some?.v kopt) (keys q).ms_elems)) (decreases q) | let rec find_max_mem_keys (kopt:option key_t) (q:forest)
: Lemma
(ensures
find_max kopt q == kopt \/
(let kopt = find_max kopt q in
Some? kopt /\ S.mem (Some?.v kopt) (keys q).ms_elems))
(decreases q) =
match q with
| [] -> ()
| Leaf::q -> find_max_mem_keys kopt q
| (Internal _ k _)::q ->
match kopt with
| None ->
find_max_mem_keys (Some k) q
| Some k' ->
let k = if k' < k then k else k' in
find_max_mem_keys (Some k) q | {
"file_name": "examples/data_structures/BinomialQueue.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 34,
"end_line": 605,
"start_col": 0,
"start_line": 589
} | (*
Copyright 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.
Authors: Aseem Rastogi
*)
module BinomialQueue
module L = FStar.List.Tot
/// Some auxiliary lemmas
let rec last_cons (#a:Type) (x:a) (l:list a)
: Lemma
(requires Cons? l)
(ensures L.last (x::l) == L.last l)
[SMTPat (L.last (x::l))] =
match l with
| [_] -> ()
| _::tl -> last_cons x tl
/// We will maintain the priority queue as a forest
type tree =
| Leaf : tree
| Internal : tree -> key_t -> tree -> tree
/// Tree t is a complete binary tree of depth d
///
/// All its keys are <= upper_bound
///
/// If the left subtree is non-empty,
/// its root is maximum in its subtree
let rec pow2heap_pred (d:nat) (upper_bound:key_t) (t:tree) : prop =
match t with
| Leaf -> d == 0
| Internal left k right ->
0 < d /\
k <= upper_bound /\
pow2heap_pred (d - 1) k left /\
pow2heap_pred (d - 1) upper_bound right
/// A power-2-heap of depth d is an Internal tree whose right child is a Leaf,
/// and left child is a complete binary tree satisfying pow2heap_pred
/// with upper bound as the key k
let is_pow2heap (d:pos) (t:tree) : prop =
match t with
| Internal left k Leaf -> pow2heap_pred (d - 1) k left
| _ -> False
/// A list of trees is a binomial queue starting with depth d if:
type forest = list tree
let rec is_binomial_queue (d:pos) (l:forest)
: Tot prop (decreases l) =
match l with
| [] -> True
| hd::tl ->
(Leaf? hd \/ is_pow2heap d hd) /\ is_binomial_queue (d + 1) tl
/// We will also keep the binomial queue in a compact form,
/// truncating unnecessary empty trees from the forest
let is_compact (l:forest) = l == [] \/ Internal? (L.last l)
let is_priq (l:forest) = is_binomial_queue 1 l /\ is_compact l
/// The main priq type
let priq = l:forest{is_priq l}
let empty = []
/// We define a function to compact a forest
let rec all_leaf (l:forest{Cons? l}) : bool =
match l with
| [Leaf] -> true
| Leaf::tl -> all_leaf tl
| _ -> false
let rec mk_compact (l:forest) : forest =
match l with
| [] -> []
| _ ->
if all_leaf l then []
else let hd::tl = l in
hd::(mk_compact tl)
/// Correctness of mk_compact
let rec mk_compact_correctness (l:forest)
: Lemma (is_compact (mk_compact l))
[SMTPat (is_compact (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_correctness (L.tl l)
let rec mk_compact_preserves_binomial_queue (d:pos) (l:forest)
: Lemma
(requires is_binomial_queue d l)
(ensures is_binomial_queue d (mk_compact l))
(decreases l)
[SMTPat (is_binomial_queue d (mk_compact l))] =
match l with
| [] -> ()
| _ ->
if all_leaf l then ()
else mk_compact_preserves_binomial_queue (d + 1) (L.tl l)
/// smash is a key function combining two power of 2 heaps of depth d
/// into a power of 2 heap of depth (d + 1)
let smash (d:pos) (t1:tree) (t2:tree)
: Pure tree
(requires is_pow2heap d t1 /\ is_pow2heap d t2)
(ensures fun t -> is_pow2heap (d + 1) t) =
match t1, t2 with
| Internal left1 k1 Leaf, Internal left2 k2 Leaf ->
if k1 <= k2
then Internal (Internal left1 k1 left2) k2 Leaf
else Internal (Internal left2 k2 left1) k1 Leaf
/// carry adds t to q, preserving the binomial queue relation
///
/// It has a nice symmetery to carry in binary arithmetic
let rec carry (d:pos) (q:forest) (t:tree)
: Pure forest
(requires is_binomial_queue d q /\ is_pow2heap d t)
(ensures fun q -> is_binomial_queue d q)
(decreases q) =
match q with
| [] -> [t]
| Leaf::tl -> t::tl
| hd::tl ->
let q = carry (d + 1) tl (smash d hd t) in
Leaf::q
/// join combines two trees p and q, with the carry c,
/// preserving the binomial queue relation
///
/// It has a nice symmetry to binary addition
let rec join (d:pos) (p q:forest) (c:tree)
: Pure forest
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c))
(ensures fun q -> is_binomial_queue d q)
(decreases L.length p) =
match p, q, c with
| [], _, Leaf -> q
| _, [], Leaf -> p
| [], _, _ -> carry d q c
| _, [], _ -> carry d p c
| Leaf::tl_p, Leaf::tl_q, _ ->
c::(join (d + 1) tl_p tl_q Leaf)
| hd_p::tl_p, Leaf::tl_q, Leaf ->
hd_p::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, Leaf ->
hd_q::(join (d + 1) tl_p tl_q Leaf)
| Leaf::tl_p, hd_q::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_q c))
| hd_p::tl_p, Leaf::tl_q, _ ->
Leaf::(join (d + 1) tl_p tl_q (smash d hd_p c))
| hd_p::tl_p, hd_q::tl_q, c ->
c::(join (d + 1) tl_p tl_q (smash d hd_p hd_q))
/// insert is just carry of (Internal Leaf x Leaf) to q
let insert x q =
let l = carry 1 q (Internal Leaf x Leaf) in
mk_compact l
/// Towards delete max
/// find_max with the current max as max
let rec find_max (max:option key_t) (q:forest)
: Tot (option key_t) (decreases q) =
match q with
| [] -> max
| Leaf::q -> find_max max q
| (Internal _ k _)::q ->
match max with
| None -> find_max (Some k) q
| Some max -> find_max (if max < k then Some k else Some max) q
/// If q is a binomial queue starting at depth d,
/// and t is a power of 2 heap of depth (d + length q)
///
/// Then appending t to q is also a binomial queue
let rec binomial_queue_append (d:pos) (q:forest) (t:tree)
: Lemma
(requires
is_binomial_queue d q /\ is_pow2heap (L.length q + d) t)
(ensures is_binomial_queue d (L.append q [t]))
(decreases q) =
match q with
| [] -> ()
| _::q -> binomial_queue_append (d + 1) q t
/// unzip splits the tree t along its right spine
///
/// See https://www.cs.princeton.edu/~appel/BQ.pdf
///
/// The upper bound is only needed to show we return a priq,
/// may be it's not important?
let rec unzip (d:nat) (upper_bound:key_t) (t:tree)
: Pure priq
(requires pow2heap_pred d upper_bound t)
(ensures fun q -> L.length q == d) =
match t with
| Leaf -> []
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
binomial_queue_append 1 q (Internal left k Leaf);
L.append_length q [Internal left k Leaf];
L.lemma_append_last q [Internal left k Leaf];
L.append q [Internal left k Leaf]
/// Delete root of t, and unzip it
let heap_delete_max (d:pos) (t:tree)
: Pure priq
(requires is_pow2heap d t)
(ensures fun q -> L.length q == d - 1) =
match t with
| Internal left k Leaf -> unzip (d - 1) k left
/// Take the first tree in q whose root is >= m,
/// delete its root and unzip it,
/// return (the deleted root, q with that tree replaces with Leaf, unzipped forest)
///
let rec delete_max_aux (m:key_t) (d:pos) (q:forest)
: Pure (key_t & forest & priq)
(requires is_binomial_queue d q)
(ensures fun (x, q, _) -> m <= x /\ is_binomial_queue d q)
(decreases q) =
match q with
| [] -> m + 1, [], [] // this case won't arise
// we could strengthen preconditions
| Leaf::q ->
let x, q, new_q = delete_max_aux m (d + 1) q in
x, Leaf::q, new_q
| (Internal left x right)::q ->
if x < m
then let y, q, new_q = delete_max_aux m (d + 1) q in
y, (Internal left x right)::q, new_q
else x, Leaf::q, heap_delete_max d (Internal left x right)
/// delete_max finds the maximum key in the forest,
/// deletes it from its tree, and joins the remaining forests
let delete_max q =
match find_max None q with
| None -> None
| Some m ->
let x, q, new_q = delete_max_aux m 1 q in
let r = join 1 q new_q Leaf in
mk_compact_correctness r;
Some (x, mk_compact r)
/// merge is just join with Leaf as the carry
let merge p q =
let l = join 1 p q Leaf in
mk_compact l
/// Towards defining repr
let rec keys_of_tree (t:tree) : ms =
match t with
| Leaf -> ms_empty
| Internal left k right ->
ms_append (keys_of_tree left)
(ms_cons k (keys_of_tree right))
let rec keys (q:forest) : ms =
match q with
| [] -> ms_empty
| hd::tl -> ms_append (keys_of_tree hd) (keys tl)
let repr_t (t:tree) (l:ms) : prop =
permutation (keys_of_tree t) l
let repr_l (q:forest) (s:ms) : prop =
permutation (keys q) s
/// The main repr predicate saying s is a permutation of (keys q)
let repr q s = repr_l q s
let empty_repr _ = ()
/// Correctness of carry and join
let smash_repr (d:pos) (t1 t2:tree) (l1 l2:ms)
: Lemma
(requires
is_pow2heap d t1 /\
is_pow2heap d t2 /\
t1 `repr_t` l1 /\
t2 `repr_t` l2)
(ensures smash d t1 t2 `repr_t` (ms_append l1 l2)) = ()
let rec carry_repr (d:pos) (q:forest) (t:tree) (lq lt:ms)
: Lemma
(requires
is_binomial_queue d q /\
is_pow2heap d t /\
q `repr_l` lq /\
t `repr_t` lt)
(ensures carry d q t `repr_l` ms_append lq lt)
(decreases q) =
match q with
| [] -> ()
| Leaf::_ -> ()
| hd::tl ->
smash_repr d hd t (keys_of_tree hd) (keys_of_tree t);
carry_repr (d + 1) tl (smash d hd t)
(keys tl)
(ms_append (keys_of_tree hd) (keys_of_tree t))
#push-options "--z3rlimit 50 --fuel 1 --ifuel 1"
let rec join_repr (d:pos) (p q:forest) (c:tree)
(lp lq lc:ms)
: Lemma
(requires
is_binomial_queue d p /\
is_binomial_queue d q /\
(Leaf? c \/ is_pow2heap d c) /\
p `repr_l` lp /\
q `repr_l` lq /\
c `repr_t` lc)
(ensures join d p q c `repr_l` ms_append lp (ms_append lq lc))
(decreases p) =
match p, q, c with
| [], _, Leaf
| _, [], Leaf -> ()
| [], _, _ -> carry_repr d q c lq lc
| _, [], _ -> carry_repr d p c lp lc
| Leaf::tl_p, Leaf::tl_q, _ ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| hd_p::tl_p, Leaf::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, Leaf ->
join_repr (d + 1) tl_p tl_q Leaf
(keys tl_p) (keys tl_q) ms_empty
| Leaf::tl_p, hd_q::tl_q, _ ->
smash_repr d hd_q c (keys_of_tree hd_q) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_q c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_q) (keys_of_tree c))
| hd_p::tl_p, Leaf::tl_q, _ ->
smash_repr d hd_p c (keys_of_tree hd_p) (keys_of_tree c);
join_repr (d + 1) tl_p tl_q (smash d hd_p c)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree c))
| hd_p::tl_p, hd_q::tl_q, c ->
smash_repr d hd_p hd_q (keys_of_tree hd_p) (keys_of_tree hd_q);
join_repr (d + 1) tl_p tl_q (smash d hd_p hd_q)
(keys tl_p) (keys tl_q)
(ms_append (keys_of_tree hd_p) (keys_of_tree hd_q))
#pop-options
/// mk_compact preserves keys
let rec all_leaf_keys (l:forest{Cons? l})
: Lemma
(requires Cons? l /\ all_leaf l)
(ensures permutation (keys l) ms_empty) =
match l with
| [Leaf] -> ()
| Leaf::tl -> all_leaf_keys tl
let rec compact_preserves_keys (q:forest)
: Lemma (permutation (keys q) (keys (mk_compact q)))
[SMTPat (keys (mk_compact q))] =
match q with
| [] -> ()
| _ ->
if all_leaf q
then all_leaf_keys q
else compact_preserves_keys (L.tl q)
/// insert and merge correctness follows from carry and joinx
let insert_repr x q s =
carry_repr 1 q (Internal Leaf x Leaf) s (ms_singleton x)
let merge_repr p q sp sq =
join_repr 1 p q Leaf sp sq ms_empty
/// Towards proof of delete correctness
let rec last_key_in_keys (l:forest)
: Lemma
(requires
Cons? l /\
Internal? (L.last l))
(ensures (let Internal _ k _ = L.last l in
S.subset (S.singleton k) (keys l).ms_elems)) =
match l with
| [Internal _ _ _] -> ()
| _::tl -> last_key_in_keys tl
let rec find_max_some_is_some (k:key_t) (l:forest)
: Lemma (ensures Some? (find_max (Some k) l) /\
k <= Some?.v (find_max (Some k) l))
(decreases l) =
match l with
| [] -> ()
| Leaf::tl -> find_max_some_is_some k tl
| (Internal _ k' _)::tl ->
let k = if k < k' then k' else k in
find_max_some_is_some k tl
let find_max_emp_repr_l (l:priq)
: Lemma
(requires l `repr_l` ms_empty)
(ensures find_max None l == None) =
match l with
| [] -> ()
| _ -> last_key_in_keys l
let rec find_max_emp_repr_r (l:forest)
: Lemma
(requires find_max None l == None)
(ensures permutation (keys l) ms_empty) =
match l with
| [] -> ()
| Leaf::tl -> find_max_emp_repr_r tl
| (Internal _ k _)::tl -> find_max_some_is_some k tl
#push-options "--warn_error -271"
let delete_max_none_repr p =
let delete_max_none_repr_l (l:priq)
: Lemma
(requires l `repr` ms_empty)
(ensures delete_max l == None)
[SMTPat ()] = find_max_emp_repr_l l in
let delete_max_none_repr_r (l:priq)
: Lemma
(requires delete_max l == None)
(ensures l `repr` ms_empty)
[SMTPat ()] = find_max_emp_repr_r l in
()
#pop-options
let rec keys_append (l1 l2:forest) (ms1 ms2:ms)
: Lemma (requires l1 `repr_l` ms1 /\ l2 `repr_l` ms2)
(ensures (L.append l1 l2) `repr_l` (ms_append ms1 ms2)) =
match l1 with
| [] -> ()
| _::tl -> keys_append tl l2 (keys tl) ms2
let rec unzip_repr (d:nat) (upper_bound:key_t) (t:tree) (lt:ms)
: Lemma
(requires
pow2heap_pred d upper_bound t /\
permutation (keys_of_tree t) lt)
(ensures permutation lt (keys (unzip d upper_bound t)))
(decreases t) =
match t with
| Leaf -> ()
| Internal left k right ->
let q = unzip (d - 1) upper_bound right in
unzip_repr (d - 1) upper_bound right (keys_of_tree right);
keys_append q [Internal left k Leaf]
(keys_of_tree right) (ms_append (keys_of_tree left)
(ms_append (ms_singleton k)
ms_empty))
let heap_delete_max_repr (d:pos) (t:tree) (lt:ms)
: Lemma
(requires is_pow2heap d t /\ t `repr_t` lt)
(ensures (
let Internal left k Leaf = t in
permutation lt (ms_append (ms_singleton k)
(keys (heap_delete_max d t))))) =
let Internal left k Leaf = t in
unzip_repr (d - 1) k left (keys_of_tree left)
let max (k:key_t) (s:S.set key_t) =
forall (x:key_t). Set.mem x s ==> x <= k
let rec tree_root_is_max_aux (d:nat) (upper_bound:key_t) (t:tree)
: Lemma
(requires pow2heap_pred d upper_bound t)
(ensures max upper_bound (keys_of_tree t).ms_elems)
(decreases t) =
match t with
| Leaf -> ()
| Internal left k right ->
tree_root_is_max_aux (d - 1) k left;
tree_root_is_max_aux (d - 1) upper_bound right
let tree_root_is_max (d:pos) (t:tree)
: Lemma
(requires is_pow2heap d t)
(ensures
(let Internal left k Leaf = t in
max k (keys_of_tree left).ms_elems)) =
let Internal left k Leaf = t in
tree_root_is_max_aux (d - 1) k left
#push-options "--z3rlimit 40"
let rec delete_max_aux_repr (m:key_t) (d:pos) (q:forest)
(x:key_t) (r:forest) (p:priq)
(lq lr lp:ms)
: Lemma
(requires
S.mem m (keys q).ms_elems /\
is_binomial_queue d q /\
q `repr_l` lq /\
delete_max_aux m d q == (x, r, p) /\
r `repr_l` lr /\
p `repr_l` lp)
(ensures
permutation lq (ms_append (ms_singleton x)
(ms_append lr lp)))
(decreases q) =
match q with
| [] -> ()
| Leaf::q ->
delete_max_aux_repr m (d + 1) q x (L.tl r) p lq lr lp
| (Internal left x Leaf)::q ->
if x < m
then begin
tree_root_is_max d (Internal left x Leaf);
assert (~ (S.mem m (keys_of_tree left).ms_elems));
let y, _, _ = delete_max_aux m (d + 1) q in
delete_max_aux_repr m (d + 1) q y (L.tl r) p (keys q) (keys (L.tl r)) lp
end
else heap_delete_max_repr d (Internal left x Leaf) (keys_of_tree (Internal left x Leaf))
#pop-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "BinomialQueue.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | kopt: FStar.Pervasives.Native.option BinomialQueue.key_t -> q: BinomialQueue.forest
-> FStar.Pervasives.Lemma
(ensures
BinomialQueue.find_max kopt q == kopt \/
(let kopt = BinomialQueue.find_max kopt q in
Some? kopt /\ FStar.Set.mem (Some?.v kopt) (Mkms?.ms_elems (BinomialQueue.keys q))))
(decreases q) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"FStar.Pervasives.Native.option",
"BinomialQueue.key_t",
"BinomialQueue.forest",
"Prims.list",
"BinomialQueue.tree",
"BinomialQueue.find_max_mem_keys",
"FStar.Pervasives.Native.Some",
"Prims.op_LessThan",
"Prims.bool",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_or",
"Prims.eq2",
"BinomialQueue.find_max",
"Prims.l_and",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"FStar.Set.mem",
"FStar.Pervasives.Native.__proj__Some__item__v",
"BinomialQueue.__proj__Mkms__item__ms_elems",
"BinomialQueue.keys",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec find_max_mem_keys (kopt: option key_t) (q: forest)
: Lemma
(ensures
find_max kopt q == kopt \/
(let kopt = find_max kopt q in
Some? kopt /\ S.mem (Some?.v kopt) (keys q).ms_elems)) (decreases q) =
| match q with
| [] -> ()
| Leaf :: q -> find_max_mem_keys kopt q
| Internal _ k _ :: q ->
match kopt with
| None -> find_max_mem_keys (Some k) q
| Some k' ->
let k = if k' < k then k else k' in
find_max_mem_keys (Some k) q | 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.