file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
FStar.FiniteMap.Ambient.fst
FStar.FiniteMap.Ambient.all_finite_map_facts_ambient
val all_finite_map_facts_ambient:squash (all_finite_map_facts u#b)
val all_finite_map_facts_ambient:squash (all_finite_map_facts u#b)
let all_finite_map_facts_ambient : squash (all_finite_map_facts u#b) = all_finite_map_facts_lemma u#b ()
{ "file_name": "ulib/FStar.FiniteMap.Ambient.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 43, "start_col": 0, "start_line": 42 }
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module brings properties about finite maps ambiently into the context. The properties are modeled after those in the Dafny sequence axioms, with patterns for quantifiers chosen as in those axioms. @summary Puts properties of finite maps into the ambient context *) module FStar.FiniteMap.Ambient open FStar.FiniteMap.Base
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FiniteMap.Base.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteMap.Ambient.fst" }
[ { "abbrev": false, "full_module": "FStar.FiniteMap.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteMap", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteMap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.squash FStar.FiniteMap.Base.all_finite_map_facts
Prims.Tot
[ "total" ]
[]
[ "FStar.FiniteMap.Base.all_finite_map_facts_lemma" ]
[]
false
false
true
true
false
let all_finite_map_facts_ambient:squash (all_finite_map_facts u#b) =
all_finite_map_facts_lemma u#b ()
false
Hacl.Spec.K256.Field52.Lemmas.fst
Hacl.Spec.K256.Field52.Lemmas.fnegate5_lemma
val fnegate5_lemma (m:scale64_5) (a:felem5) (x:uint64) : Lemma (requires (let (m0,m1,m2,m3,m4) = m in 2 * v x <= 4096 /\ m0 <= v x /\ m1 <= v x /\ m2 <= v x /\ m3 <= v x /\ m4 <= v x /\ felem_fits5 a m)) (ensures (let r = fnegate5 a x in let xn = v x in as_nat5 r = 2 * v x * S.prime - as_nat5 a /\ felem_fits5 r (2*xn,2*xn,2*xn,2*xn,2*xn)))
val fnegate5_lemma (m:scale64_5) (a:felem5) (x:uint64) : Lemma (requires (let (m0,m1,m2,m3,m4) = m in 2 * v x <= 4096 /\ m0 <= v x /\ m1 <= v x /\ m2 <= v x /\ m3 <= v x /\ m4 <= v x /\ felem_fits5 a m)) (ensures (let r = fnegate5 a x in let xn = v x in as_nat5 r = 2 * v x * S.prime - as_nat5 a /\ felem_fits5 r (2*xn,2*xn,2*xn,2*xn,2*xn)))
let fnegate5_lemma m a x = let xn = v x in let (a0,a1,a2,a3,a4) = a in let (m0,m1,m2,m3,m4) = m in let r0 = u64 0xffffefffffc2f *. u64 2 *. x -. a0 in assert_norm (0xffffefffffc2f < max52); assert_norm (max52 < 0xffffefffffc2f * 2); lemma_mul_sub m0 (u64 0xffffefffffc2f) x a0; let r1 = u64 0xfffffffffffff *. u64 2 *. x -. a1 in assert_norm (0xfffffffffffff <= max52); assert_norm (max52 <= 0xfffffffffffff * 2); lemma_mul_sub m1 (u64 0xfffffffffffff) x a1; let r2 = u64 0xfffffffffffff *. u64 2 *. x -. a2 in lemma_mul_sub m2 (u64 0xfffffffffffff) x a2; let r3 = u64 0xfffffffffffff *. u64 2 *. x -. a3 in lemma_mul_sub m3 (u64 0xfffffffffffff) x a3; let r4 = u64 0xffffffffffff *. u64 2 *. x -. a4 in assert_norm (0xffffffffffff <= max48); assert_norm (max48 <= 0xffffffffffff * 2); lemma_mul_sub_last m4 (u64 0xffffffffffff) x a4; let r = (r0,r1,r2,r3,r4) in assert (felem_fits5 r (2*xn,2*xn,2*xn,2*xn,2*xn)); assert (as_nat5 r = 0xffffefffffc2f * 2 * v x - v a0 + (0xfffffffffffff * 2 * v x - v a1) * pow52 + (0xfffffffffffff * 2 * v x - v a2) * pow104 + (0xfffffffffffff * 2 * v x - v a3) * pow156 + (0xffffffffffff * 2 * v x - v a4) * pow208); calc (==) { 0xffffefffffc2f * 2 * v x - v a0 + (0xfffffffffffff * 2 * v x - v a1) * pow52 + (0xfffffffffffff * 2 * v x - v a2) * pow104 + (0xfffffffffffff * 2 * v x - v a3) * pow156 + (0xffffffffffff * 2 * v x - v a4) * pow208; (==) { Math.Lemmas.paren_mul_right 0xffffefffffc2f 2 (v x); Math.Lemmas.paren_mul_right 0xfffffffffffff 2 (v x); Math.Lemmas.paren_mul_right 0xffffffffffff 2 (v x); ML.lemma_distr5_pow52_sub (v a0) (v a1) (v a2) (v a3) (v a4) 0xffffefffffc2f 0xfffffffffffff 0xfffffffffffff 0xfffffffffffff 0xffffffffffff (2 * v x) } - as_nat5 a + 2 * v x * (0xffffefffffc2f + 0xfffffffffffff * pow52 + 0xfffffffffffff * pow104 + 0xfffffffffffff * pow156 + 0xffffffffffff * pow208); (==) { assert_norm (0xffffefffffc2f + 0xfffffffffffff * pow52 + 0xfffffffffffff * pow104 + 0xfffffffffffff * pow156 + 0xffffffffffff * pow208 = S.prime) } - as_nat5 a + 2 * v x * S.prime; }; assert (as_nat5 r = 2 * v x * S.prime - as_nat5 a)
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 216, "start_col": 0, "start_line": 163 }
module Hacl.Spec.K256.Field52.Lemmas 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 module L1 = Hacl.Spec.K256.Field52.Lemmas1 module L2 = Hacl.Spec.K256.Field52.Lemmas2 module L3 = Hacl.Spec.K256.Field52.Lemmas3 #set-options "--z3rlimit 100 --fuel 0 --ifuel 0" let load_felem5_lemma s = L1.load_felem5_lemma s let store_felem5_lemma f = L1.store_felem5_lemma f let add5_lemma m1 m2 f1 f2 = L1.add5_lemma m1 m2 f1 f2 let fadd5_lemma m1 m2 f1 f2 = let r = add5 f1 f2 in add5_lemma m1 m2 f1 f2; assert (as_nat5 r == as_nat5 f1 + as_nat5 f2); Math.Lemmas.modulo_distributivity (as_nat5 f1) (as_nat5 f2) S.prime let mul15_lemma m1 m2 f c = L1.mul15_lemma m1 m2 f c let fmul15_lemma m1 m2 f c = let r = mul15 f c in mul15_lemma m1 m2 f c; assert (as_nat5 r == v c * as_nat5 f); Math.Lemmas.lemma_mod_mul_distr_r (v c) (as_nat5 f) S.prime #push-options "--ifuel 1" let is_felem_zero_vartime5_lemma f = () let is_felem_ge_prime_vartime5_lemma f = let p = (u64 0xffffefffffc2f, u64 0xfffffffffffff, u64 0xfffffffffffff, u64 0xfffffffffffff, u64 0xffffffffffff) in assert_norm (S.prime = as_nat5 p); assert_norm (0xffffefffffc2f <= max52); assert_norm (0xfffffffffffff = max52); assert_norm (0xffffffffffff = max48); assert (felem_fits5 p (1,1,1,1,1)); //LD.lemma_as_nat_decompose f; //LD.lemma_as_nat_decompose p; LD.lemma_as_nat_bound f; LD.lemma_as_nat_bound p let is_felem_lt_prime_minus_order_vartime5_lemma f = assert_norm (S.prime - S.q = 0xda1722fc9baee + 0x1950b75fc4402 * pow52 + 0x1455123 * pow104) let is_felem_eq_vartime5_lemma f1 f2 = if as_nat5 f1 = as_nat5 f2 then LD.as_nat_inj f1 f2 #pop-options let normalize_weak5_lemma m f = let r = normalize_weak5 f in let (t0,t1,t2,t3,t4) = f in L2.normalize_weak5_lemma m f; assert (as_nat5 r == as_nat5 f - v t4 / pow2 48 * S.prime); Math.Lemmas.lemma_mod_sub (as_nat5 f) S.prime (v t4 / pow2 48) let normalize5_lemma m f = L2.normalize5_lemma m f let fmul5_lemma a b = L3.fmul5_lemma a b let fmul5_lemma1 a b = let r = fmul5 a b in L3.fmul5_lemma a b; assert (as_nat5 r % S.prime == as_nat5 a * as_nat5 b % S.prime); ML.lemma_mod_mul_distr (as_nat5 a) (as_nat5 b) S.prime let fsqr5_lemma a = L3.fsqr5_lemma a let fsqr5_lemma1 a = let r = fsqr5 a in L3.fsqr5_lemma a; assert (as_nat5 r % S.prime == as_nat5 a * as_nat5 a % S.prime); ML.lemma_mod_mul_distr (as_nat5 a) (as_nat5 a) S.prime val lemma_mul_sub (mc:nat) (a b c:uint64) : Lemma (requires v a <= max52 /\ max52 <= v a * 2 /\ v c <= mc * max52 /\ mc <= v b /\ 2 * v b <= 4096) (ensures (let r = a *. u64 2 *. b -. c in v r = v a * 2 * v b - v c /\ felem_fits1 r (2 * v b))) let lemma_mul_sub mc a b c = let r = a *. u64 2 *. b -. c in assert (v c <= mc * max52); ML.lemma_ab_le_cd mc max52 (v b) (v a * 2); assert (v c <= v a * 2 * v b); assert (v a * 2 * v b - v c <= v a * 2 * v b); Math.Lemmas.paren_mul_right (v a) 2 (v b); ML.lemma_ab_le_cd (v a) (2 * v b) max52 4096; assert_norm (4096 * max52 < pow2 64); Math.Lemmas.small_mod (v a * 2 * v b - v c) (pow2 64); assert (v r = v a * 2 * v b - v c); ML.lemma_ab_le_cd (v a) (2 * v b) max52 (2 * v b); assert (felem_fits1 r (2 * v b)) val lemma_mul_sub_last (mc:nat) (a b c:uint64) : Lemma (requires v a <= max48 /\ max48 <= v a * 2 /\ v c <= mc * max48 /\ mc <= v b /\ 2 * v b <= 65536) (ensures (let r = a *. u64 2 *. b -. c in v r = v a * 2 * v b - v c /\ felem_fits_last1 r (2 * v b))) let lemma_mul_sub_last mc a b c = let r = a *. u64 2 *. b -. c in assert (v c <= mc * max48); ML.lemma_ab_le_cd mc max48 (v b) (v a * 2); assert (v c <= v b * (v a * 2)); assert (v a * 2 * v b - v c <= v a * 2 * v b); Math.Lemmas.paren_mul_right (v a) 2 (v b); ML.lemma_ab_le_cd (v a) (2 * v b) max48 65536; assert_norm (65536 * max48 < pow2 64); Math.Lemmas.small_mod (v a * 2 * v b - v c) (pow2 64); assert (v r = v a * 2 * v b - v c); ML.lemma_ab_le_cd (v a) (2 * v b) max48 (2 * v b); assert (felem_fits_last1 r (2 * v b))
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.MathLemmas.fst.checked", "Hacl.Spec.K256.Field52.Lemmas3.fst.checked", "Hacl.Spec.K256.Field52.Lemmas2.fst.checked", "Hacl.Spec.K256.Field52.Lemmas1.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.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.K256.Field52.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas3", "short_module": "L3" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas2", "short_module": "L2" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas1", "short_module": "L1" }, { "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.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
m: Hacl.Spec.K256.Field52.Definitions.scale64_5 -> a: Hacl.Spec.K256.Field52.Definitions.felem5 -> x: Lib.IntTypes.uint64 -> FStar.Pervasives.Lemma (requires (let _ = m in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ m0 m1 m2 m3 m4 = _ in 2 * Lib.IntTypes.v x <= 4096 /\ m0 <= Lib.IntTypes.v x /\ m1 <= Lib.IntTypes.v x /\ m2 <= Lib.IntTypes.v x /\ m3 <= Lib.IntTypes.v x /\ m4 <= Lib.IntTypes.v x /\ Hacl.Spec.K256.Field52.Definitions.felem_fits5 a m) <: Type0)) (ensures (let r = Hacl.Spec.K256.Field52.fnegate5 a x in let xn = Lib.IntTypes.v x in Hacl.Spec.K256.Field52.Definitions.as_nat5 r = (2 * Lib.IntTypes.v x) * Spec.K256.PointOps.prime - Hacl.Spec.K256.Field52.Definitions.as_nat5 a /\ Hacl.Spec.K256.Field52.Definitions.felem_fits5 r (2 * xn, 2 * xn, 2 * xn, 2 * xn, 2 * xn)) )
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.scale64_5", "Hacl.Spec.K256.Field52.Definitions.felem5", "Lib.IntTypes.uint64", "Prims.nat", "Prims._assert", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Hacl.Spec.K256.Field52.Definitions.as_nat5", "Prims.op_Subtraction", "FStar.Mul.op_Star", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Spec.K256.PointOps.prime", "Prims.unit", "FStar.Calc.calc_finish", "Prims.eq2", "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.op_Minus", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Hacl.Spec.K256.MathLemmas.lemma_distr5_pow52_sub", "FStar.Math.Lemmas.paren_mul_right", "Prims.squash", "FStar.Pervasives.assert_norm", "Hacl.Spec.K256.Field52.Definitions.felem_fits5", "FStar.Pervasives.Native.Mktuple5", "FStar.Pervasives.Native.tuple5", "Lib.IntTypes.int_t", "Hacl.Spec.K256.Field52.Lemmas.lemma_mul_sub_last", "Lib.IntTypes.u64", "Prims.op_LessThanOrEqual", "Hacl.Spec.K256.Field52.Definitions.max48", "Lib.IntTypes.op_Subtraction_Dot", "Lib.IntTypes.op_Star_Dot", "Hacl.Spec.K256.Field52.Lemmas.lemma_mul_sub", "Hacl.Spec.K256.Field52.Definitions.max52", "Prims.op_LessThan", "Lib.IntTypes.range" ]
[]
false
false
true
false
false
let fnegate5_lemma m a x =
let xn = v x in let a0, a1, a2, a3, a4 = a in let m0, m1, m2, m3, m4 = m in let r0 = u64 0xffffefffffc2f *. u64 2 *. x -. a0 in assert_norm (0xffffefffffc2f < max52); assert_norm (max52 < 0xffffefffffc2f * 2); lemma_mul_sub m0 (u64 0xffffefffffc2f) x a0; let r1 = u64 0xfffffffffffff *. u64 2 *. x -. a1 in assert_norm (0xfffffffffffff <= max52); assert_norm (max52 <= 0xfffffffffffff * 2); lemma_mul_sub m1 (u64 0xfffffffffffff) x a1; let r2 = u64 0xfffffffffffff *. u64 2 *. x -. a2 in lemma_mul_sub m2 (u64 0xfffffffffffff) x a2; let r3 = u64 0xfffffffffffff *. u64 2 *. x -. a3 in lemma_mul_sub m3 (u64 0xfffffffffffff) x a3; let r4 = u64 0xffffffffffff *. u64 2 *. x -. a4 in assert_norm (0xffffffffffff <= max48); assert_norm (max48 <= 0xffffffffffff * 2); lemma_mul_sub_last m4 (u64 0xffffffffffff) x a4; let r = (r0, r1, r2, r3, r4) in assert (felem_fits5 r (2 * xn, 2 * xn, 2 * xn, 2 * xn, 2 * xn)); assert (as_nat5 r = (0xffffefffffc2f * 2) * v x - v a0 + ((0xfffffffffffff * 2) * v x - v a1) * pow52 + ((0xfffffffffffff * 2) * v x - v a2) * pow104 + ((0xfffffffffffff * 2) * v x - v a3) * pow156 + ((0xffffffffffff * 2) * v x - v a4) * pow208); calc ( == ) { (0xffffefffffc2f * 2) * v x - v a0 + ((0xfffffffffffff * 2) * v x - v a1) * pow52 + ((0xfffffffffffff * 2) * v x - v a2) * pow104 + ((0xfffffffffffff * 2) * v x - v a3) * pow156 + ((0xffffffffffff * 2) * v x - v a4) * pow208; ( == ) { (Math.Lemmas.paren_mul_right 0xffffefffffc2f 2 (v x); Math.Lemmas.paren_mul_right 0xfffffffffffff 2 (v x); Math.Lemmas.paren_mul_right 0xffffffffffff 2 (v x); ML.lemma_distr5_pow52_sub (v a0) (v a1) (v a2) (v a3) (v a4) 0xffffefffffc2f 0xfffffffffffff 0xfffffffffffff 0xfffffffffffff 0xffffffffffff (2 * v x)) } - as_nat5 a + (2 * v x) * (0xffffefffffc2f + 0xfffffffffffff * pow52 + 0xfffffffffffff * pow104 + 0xfffffffffffff * pow156 + 0xffffffffffff * pow208); ( == ) { assert_norm (0xffffefffffc2f + 0xfffffffffffff * pow52 + 0xfffffffffffff * pow104 + 0xfffffffffffff * pow156 + 0xffffffffffff * pow208 = S.prime) } - as_nat5 a + (2 * v x) * S.prime; }; assert (as_nat5 r = (2 * v x) * S.prime - as_nat5 a)
false
FStar.DependentMap.fst
FStar.DependentMap.sel
val sel (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) : Tot (value k)
val sel (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) : Tot (value k)
let sel (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) : Tot (value k) = m.mappings k
{ "file_name": "ulib/FStar.DependentMap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 14, "end_line": 27, "start_col": 0, "start_line": 26 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DependentMap module F = FStar.FunctionalExtensionality noeq type t (key: eqtype) (value: (key -> Type)) = { mappings:F.restricted_t key value } let create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) : Tot (t key value) = { mappings = F.on_domain key f }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.DependentMap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.DependentMap.t key value -> k: key -> value k
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "FStar.DependentMap.t", "FStar.DependentMap.__proj__Mkt__item__mappings" ]
[]
false
false
false
false
false
let sel (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) : Tot (value k) =
m.mappings k
false
FStar.DependentMap.fst
FStar.DependentMap.create
val create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) : Tot (t key value)
val create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) : Tot (t key value)
let create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) : Tot (t key value) = { mappings = F.on_domain key f }
{ "file_name": "ulib/FStar.DependentMap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 58, "end_line": 24, "start_col": 0, "start_line": 23 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DependentMap module F = FStar.FunctionalExtensionality noeq type t (key: eqtype) (value: (key -> Type)) = { mappings:F.restricted_t key value }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.DependentMap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (k: key -> value k) -> FStar.DependentMap.t key value
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "FStar.DependentMap.Mkt", "FStar.FunctionalExtensionality.on_domain", "FStar.DependentMap.t" ]
[]
false
false
false
false
false
let create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) : Tot (t key value) =
{ mappings = F.on_domain key f }
false
Hacl.Spec.K256.Field52.Lemmas.fst
Hacl.Spec.K256.Field52.Lemmas.lemma_mul_sub_last
val lemma_mul_sub_last (mc:nat) (a b c:uint64) : Lemma (requires v a <= max48 /\ max48 <= v a * 2 /\ v c <= mc * max48 /\ mc <= v b /\ 2 * v b <= 65536) (ensures (let r = a *. u64 2 *. b -. c in v r = v a * 2 * v b - v c /\ felem_fits_last1 r (2 * v b)))
val lemma_mul_sub_last (mc:nat) (a b c:uint64) : Lemma (requires v a <= max48 /\ max48 <= v a * 2 /\ v c <= mc * max48 /\ mc <= v b /\ 2 * v b <= 65536) (ensures (let r = a *. u64 2 *. b -. c in v r = v a * 2 * v b - v c /\ felem_fits_last1 r (2 * v b)))
let lemma_mul_sub_last mc a b c = let r = a *. u64 2 *. b -. c in assert (v c <= mc * max48); ML.lemma_ab_le_cd mc max48 (v b) (v a * 2); assert (v c <= v b * (v a * 2)); assert (v a * 2 * v b - v c <= v a * 2 * v b); Math.Lemmas.paren_mul_right (v a) 2 (v b); ML.lemma_ab_le_cd (v a) (2 * v b) max48 65536; assert_norm (65536 * max48 < pow2 64); Math.Lemmas.small_mod (v a * 2 * v b - v c) (pow2 64); assert (v r = v a * 2 * v b - v c); ML.lemma_ab_le_cd (v a) (2 * v b) max48 (2 * v b); assert (felem_fits_last1 r (2 * v b))
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 160, "start_col": 0, "start_line": 146 }
module Hacl.Spec.K256.Field52.Lemmas 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 module L1 = Hacl.Spec.K256.Field52.Lemmas1 module L2 = Hacl.Spec.K256.Field52.Lemmas2 module L3 = Hacl.Spec.K256.Field52.Lemmas3 #set-options "--z3rlimit 100 --fuel 0 --ifuel 0" let load_felem5_lemma s = L1.load_felem5_lemma s let store_felem5_lemma f = L1.store_felem5_lemma f let add5_lemma m1 m2 f1 f2 = L1.add5_lemma m1 m2 f1 f2 let fadd5_lemma m1 m2 f1 f2 = let r = add5 f1 f2 in add5_lemma m1 m2 f1 f2; assert (as_nat5 r == as_nat5 f1 + as_nat5 f2); Math.Lemmas.modulo_distributivity (as_nat5 f1) (as_nat5 f2) S.prime let mul15_lemma m1 m2 f c = L1.mul15_lemma m1 m2 f c let fmul15_lemma m1 m2 f c = let r = mul15 f c in mul15_lemma m1 m2 f c; assert (as_nat5 r == v c * as_nat5 f); Math.Lemmas.lemma_mod_mul_distr_r (v c) (as_nat5 f) S.prime #push-options "--ifuel 1" let is_felem_zero_vartime5_lemma f = () let is_felem_ge_prime_vartime5_lemma f = let p = (u64 0xffffefffffc2f, u64 0xfffffffffffff, u64 0xfffffffffffff, u64 0xfffffffffffff, u64 0xffffffffffff) in assert_norm (S.prime = as_nat5 p); assert_norm (0xffffefffffc2f <= max52); assert_norm (0xfffffffffffff = max52); assert_norm (0xffffffffffff = max48); assert (felem_fits5 p (1,1,1,1,1)); //LD.lemma_as_nat_decompose f; //LD.lemma_as_nat_decompose p; LD.lemma_as_nat_bound f; LD.lemma_as_nat_bound p let is_felem_lt_prime_minus_order_vartime5_lemma f = assert_norm (S.prime - S.q = 0xda1722fc9baee + 0x1950b75fc4402 * pow52 + 0x1455123 * pow104) let is_felem_eq_vartime5_lemma f1 f2 = if as_nat5 f1 = as_nat5 f2 then LD.as_nat_inj f1 f2 #pop-options let normalize_weak5_lemma m f = let r = normalize_weak5 f in let (t0,t1,t2,t3,t4) = f in L2.normalize_weak5_lemma m f; assert (as_nat5 r == as_nat5 f - v t4 / pow2 48 * S.prime); Math.Lemmas.lemma_mod_sub (as_nat5 f) S.prime (v t4 / pow2 48) let normalize5_lemma m f = L2.normalize5_lemma m f let fmul5_lemma a b = L3.fmul5_lemma a b let fmul5_lemma1 a b = let r = fmul5 a b in L3.fmul5_lemma a b; assert (as_nat5 r % S.prime == as_nat5 a * as_nat5 b % S.prime); ML.lemma_mod_mul_distr (as_nat5 a) (as_nat5 b) S.prime let fsqr5_lemma a = L3.fsqr5_lemma a let fsqr5_lemma1 a = let r = fsqr5 a in L3.fsqr5_lemma a; assert (as_nat5 r % S.prime == as_nat5 a * as_nat5 a % S.prime); ML.lemma_mod_mul_distr (as_nat5 a) (as_nat5 a) S.prime val lemma_mul_sub (mc:nat) (a b c:uint64) : Lemma (requires v a <= max52 /\ max52 <= v a * 2 /\ v c <= mc * max52 /\ mc <= v b /\ 2 * v b <= 4096) (ensures (let r = a *. u64 2 *. b -. c in v r = v a * 2 * v b - v c /\ felem_fits1 r (2 * v b))) let lemma_mul_sub mc a b c = let r = a *. u64 2 *. b -. c in assert (v c <= mc * max52); ML.lemma_ab_le_cd mc max52 (v b) (v a * 2); assert (v c <= v a * 2 * v b); assert (v a * 2 * v b - v c <= v a * 2 * v b); Math.Lemmas.paren_mul_right (v a) 2 (v b); ML.lemma_ab_le_cd (v a) (2 * v b) max52 4096; assert_norm (4096 * max52 < pow2 64); Math.Lemmas.small_mod (v a * 2 * v b - v c) (pow2 64); assert (v r = v a * 2 * v b - v c); ML.lemma_ab_le_cd (v a) (2 * v b) max52 (2 * v b); assert (felem_fits1 r (2 * v b)) val lemma_mul_sub_last (mc:nat) (a b c:uint64) : Lemma (requires v a <= max48 /\ max48 <= v a * 2 /\ v c <= mc * max48 /\ mc <= v b /\ 2 * v b <= 65536) (ensures (let r = a *. u64 2 *. b -. c in v r = v a * 2 * v b - v c /\ felem_fits_last1 r (2 * v b)))
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.MathLemmas.fst.checked", "Hacl.Spec.K256.Field52.Lemmas3.fst.checked", "Hacl.Spec.K256.Field52.Lemmas2.fst.checked", "Hacl.Spec.K256.Field52.Lemmas1.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.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.K256.Field52.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas3", "short_module": "L3" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas2", "short_module": "L2" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas1", "short_module": "L1" }, { "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.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
mc: Prims.nat -> a: Lib.IntTypes.uint64 -> b: Lib.IntTypes.uint64 -> c: Lib.IntTypes.uint64 -> FStar.Pervasives.Lemma (requires Lib.IntTypes.v a <= Hacl.Spec.K256.Field52.Definitions.max48 /\ Hacl.Spec.K256.Field52.Definitions.max48 <= Lib.IntTypes.v a * 2 /\ Lib.IntTypes.v c <= mc * Hacl.Spec.K256.Field52.Definitions.max48 /\ mc <= Lib.IntTypes.v b /\ 2 * Lib.IntTypes.v b <= 65536) (ensures (let r = a *. Lib.IntTypes.u64 2 *. b -. c in Lib.IntTypes.v r = (Lib.IntTypes.v a * 2) * Lib.IntTypes.v b - Lib.IntTypes.v c /\ Hacl.Spec.K256.Field52.Definitions.felem_fits_last1 r (2 * Lib.IntTypes.v b)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "Lib.IntTypes.uint64", "Prims._assert", "Prims.b2t", "Hacl.Spec.K256.Field52.Definitions.felem_fits_last1", "FStar.Mul.op_Star", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.unit", "Hacl.Spec.K256.MathLemmas.lemma_ab_le_cd", "Hacl.Spec.K256.Field52.Definitions.max48", "Prims.op_Equality", "Prims.int", "Prims.op_Subtraction", "FStar.Math.Lemmas.small_mod", "Prims.pow2", "FStar.Pervasives.assert_norm", "Prims.op_LessThan", "FStar.Math.Lemmas.paren_mul_right", "Prims.op_LessThanOrEqual", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Subtraction_Dot", "Lib.IntTypes.op_Star_Dot", "Lib.IntTypes.u64" ]
[]
true
false
true
false
false
let lemma_mul_sub_last mc a b c =
let r = a *. u64 2 *. b -. c in assert (v c <= mc * max48); ML.lemma_ab_le_cd mc max48 (v b) (v a * 2); assert (v c <= v b * (v a * 2)); assert ((v a * 2) * v b - v c <= (v a * 2) * v b); Math.Lemmas.paren_mul_right (v a) 2 (v b); ML.lemma_ab_le_cd (v a) (2 * v b) max48 65536; assert_norm (65536 * max48 < pow2 64); Math.Lemmas.small_mod ((v a * 2) * v b - v c) (pow2 64); assert (v r = (v a * 2) * v b - v c); ML.lemma_ab_le_cd (v a) (2 * v b) max48 (2 * v b); assert (felem_fits_last1 r (2 * v b))
false
FStar.DependentMap.fst
FStar.DependentMap.equal
val equal (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) : prop
val equal (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) : prop
let equal (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = forall k. sel m1 k == sel m2 k
{ "file_name": "ulib/FStar.DependentMap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 32, "end_line": 51, "start_col": 0, "start_line": 50 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DependentMap module F = FStar.FunctionalExtensionality noeq type t (key: eqtype) (value: (key -> Type)) = { mappings:F.restricted_t key value } let create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) : Tot (t key value) = { mappings = F.on_domain key f } let sel (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) : Tot (value k) = m.mappings k let sel_create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) (k: key) : Lemma (requires True) (ensures (sel #key #value (create f) k == f k)) [SMTPat (sel #key #value (create f) k)] = () let upd (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) : Tot (t key value) = { mappings = F.on_domain key (fun k' -> if k' = k then v else m.mappings k') } let sel_upd_same (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) = () let sel_upd_other (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) (k': key) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.DependentMap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m1: FStar.DependentMap.t key value -> m2: FStar.DependentMap.t key value -> Prims.prop
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "FStar.DependentMap.t", "Prims.l_Forall", "Prims.eq2", "FStar.DependentMap.sel", "Prims.prop" ]
[]
false
false
false
false
true
let equal (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) =
forall k. sel m1 k == sel m2 k
false
FStar.DependentMap.fst
FStar.DependentMap.upd
val upd (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) : Tot (t key value)
val upd (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) : Tot (t key value)
let upd (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) : Tot (t key value) = { mappings = F.on_domain key (fun k' -> if k' = k then v else m.mappings k') }
{ "file_name": "ulib/FStar.DependentMap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 80, "end_line": 36, "start_col": 0, "start_line": 34 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DependentMap module F = FStar.FunctionalExtensionality noeq type t (key: eqtype) (value: (key -> Type)) = { mappings:F.restricted_t key value } let create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) : Tot (t key value) = { mappings = F.on_domain key f } let sel (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) : Tot (value k) = m.mappings k let sel_create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) (k: key) : Lemma (requires True) (ensures (sel #key #value (create f) k == f k)) [SMTPat (sel #key #value (create f) k)] = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.DependentMap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.DependentMap.t key value -> k: key -> v: value k -> FStar.DependentMap.t key value
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "FStar.DependentMap.t", "FStar.DependentMap.Mkt", "FStar.FunctionalExtensionality.on_domain", "Prims.op_Equality", "Prims.bool", "FStar.DependentMap.__proj__Mkt__item__mappings" ]
[]
false
false
false
false
false
let upd (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) : Tot (t key value) =
{ mappings = F.on_domain key (fun k' -> if k' = k then v else m.mappings k') }
false
FStar.DependentMap.fst
FStar.DependentMap.concat_mappings
val concat_mappings (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: (k1: key1 -> Tot (value1 k1))) (m2: (k2: key2 -> Tot (value2 k2))) (k: either key1 key2) : concat_value value1 value2 k
val concat_mappings (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: (k1: key1 -> Tot (value1 k1))) (m2: (k2: key2 -> Tot (value2 k2))) (k: either key1 key2) : concat_value value1 value2 k
let concat_mappings (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: (k1: key1 -> Tot (value1 k1))) (m2: (k2: key2 -> Tot (value2 k2))) (k: either key1 key2) : concat_value value1 value2 k = match k with | Inl k1 -> m1 k1 | Inr k2 -> m2 k2
{ "file_name": "ulib/FStar.DependentMap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 19, "end_line": 82, "start_col": 0, "start_line": 71 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DependentMap module F = FStar.FunctionalExtensionality noeq type t (key: eqtype) (value: (key -> Type)) = { mappings:F.restricted_t key value } let create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) : Tot (t key value) = { mappings = F.on_domain key f } let sel (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) : Tot (value k) = m.mappings k let sel_create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) (k: key) : Lemma (requires True) (ensures (sel #key #value (create f) k == f k)) [SMTPat (sel #key #value (create f) k)] = () let upd (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) : Tot (t key value) = { mappings = F.on_domain key (fun k' -> if k' = k then v else m.mappings k') } let sel_upd_same (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) = () let sel_upd_other (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) (k': key) = () let equal (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = forall k. sel m1 k == sel m2 k let equal_intro (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = () let equal_refl (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) = () let equal_elim (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = F.extensionality key value m1.mappings m2.mappings let restrict (#key: eqtype) (#value: (key -> Tot Type)) (p: (key -> Tot Type0)) (m: t key value) = { mappings = F.on_domain (k: key{p k}) m.mappings } let sel_restrict (#key: eqtype) (#value: (key -> Tot Type)) (p: (key -> Tot Type0)) (m: t key value) (k: key{p k}) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.DependentMap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m1: (k1: key1 -> value1 k1) -> m2: (k2: key2 -> value2 k2) -> k: FStar.Pervasives.either key1 key2 -> FStar.DependentMap.concat_value value1 value2 k
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "FStar.Pervasives.either", "FStar.DependentMap.concat_value" ]
[]
false
false
false
false
false
let concat_mappings (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: (k1: key1 -> Tot (value1 k1))) (m2: (k2: key2 -> Tot (value2 k2))) (k: either key1 key2) : concat_value value1 value2 k =
match k with | Inl k1 -> m1 k1 | Inr k2 -> m2 k2
false
FStar.DependentMap.fst
FStar.DependentMap.restrict
val restrict (#key: eqtype) (#value: (key -> Tot Type)) (p: (key -> Tot Type0)) (m: t key value) : Tot (t (k: key{p k}) value)
val restrict (#key: eqtype) (#value: (key -> Tot Type)) (p: (key -> Tot Type0)) (m: t key value) : Tot (t (k: key{p k}) value)
let restrict (#key: eqtype) (#value: (key -> Tot Type)) (p: (key -> Tot Type0)) (m: t key value) = { mappings = F.on_domain (k: key{p k}) m.mappings }
{ "file_name": "ulib/FStar.DependentMap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 53, "end_line": 61, "start_col": 0, "start_line": 60 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DependentMap module F = FStar.FunctionalExtensionality noeq type t (key: eqtype) (value: (key -> Type)) = { mappings:F.restricted_t key value } let create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) : Tot (t key value) = { mappings = F.on_domain key f } let sel (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) : Tot (value k) = m.mappings k let sel_create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) (k: key) : Lemma (requires True) (ensures (sel #key #value (create f) k == f k)) [SMTPat (sel #key #value (create f) k)] = () let upd (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) : Tot (t key value) = { mappings = F.on_domain key (fun k' -> if k' = k then v else m.mappings k') } let sel_upd_same (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) = () let sel_upd_other (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) (k': key) = () let equal (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = forall k. sel m1 k == sel m2 k let equal_intro (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = () let equal_refl (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) = () let equal_elim (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = F.extensionality key value m1.mappings m2.mappings
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.DependentMap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: key -> Type0) -> m: FStar.DependentMap.t key value -> FStar.DependentMap.t (k: key{p k}) value
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "FStar.DependentMap.t", "FStar.DependentMap.Mkt", "FStar.FunctionalExtensionality.on_domain", "FStar.DependentMap.__proj__Mkt__item__mappings" ]
[]
false
false
false
false
false
let restrict (#key: eqtype) (#value: (key -> Tot Type)) (p: (key -> Tot Type0)) (m: t key value) =
{ mappings = F.on_domain (k: key{p k}) m.mappings }
false
FStar.DependentMap.fst
FStar.DependentMap.equal_elim
val equal_elim (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) : Lemma (requires (equal m1 m2)) (ensures (m1 == m2)) [SMTPat (equal m1 m2)]
val equal_elim (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) : Lemma (requires (equal m1 m2)) (ensures (m1 == m2)) [SMTPat (equal m1 m2)]
let equal_elim (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = F.extensionality key value m1.mappings m2.mappings
{ "file_name": "ulib/FStar.DependentMap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 52, "end_line": 58, "start_col": 0, "start_line": 57 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DependentMap module F = FStar.FunctionalExtensionality noeq type t (key: eqtype) (value: (key -> Type)) = { mappings:F.restricted_t key value } let create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) : Tot (t key value) = { mappings = F.on_domain key f } let sel (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) : Tot (value k) = m.mappings k let sel_create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) (k: key) : Lemma (requires True) (ensures (sel #key #value (create f) k == f k)) [SMTPat (sel #key #value (create f) k)] = () let upd (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) : Tot (t key value) = { mappings = F.on_domain key (fun k' -> if k' = k then v else m.mappings k') } let sel_upd_same (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) = () let sel_upd_other (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) (k': key) = () let equal (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = forall k. sel m1 k == sel m2 k let equal_intro (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = () let equal_refl (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.DependentMap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m1: FStar.DependentMap.t key value -> m2: FStar.DependentMap.t key value -> FStar.Pervasives.Lemma (requires FStar.DependentMap.equal m1 m2) (ensures m1 == m2) [SMTPat (FStar.DependentMap.equal m1 m2)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "FStar.DependentMap.t", "FStar.FunctionalExtensionality.extensionality", "FStar.DependentMap.__proj__Mkt__item__mappings", "Prims.unit" ]
[]
true
false
true
false
false
let equal_elim (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) =
F.extensionality key value m1.mappings m2.mappings
false
FStar.DependentMap.fst
FStar.DependentMap.concat
val concat (#key1: eqtype) (#value1: (key1 -> Tot (Type u#v))) (#key2: eqtype) (#value2: (key2 -> Tot (Type u#v))) (m1: t key1 value1) (m2: t key2 value2) : Tot (t (either key1 key2) (concat_value value1 value2))
val concat (#key1: eqtype) (#value1: (key1 -> Tot (Type u#v))) (#key2: eqtype) (#value2: (key2 -> Tot (Type u#v))) (m1: t key1 value1) (m2: t key2 value2) : Tot (t (either key1 key2) (concat_value value1 value2))
let concat (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: t key1 value1) (m2: t key2 value2) : Tot (t (either key1 key2) (concat_value value1 value2)) = { mappings = F.on_domain (either key1 key2) (concat_mappings m1.mappings m2.mappings) }
{ "file_name": "ulib/FStar.DependentMap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 89, "end_line": 92, "start_col": 0, "start_line": 84 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DependentMap module F = FStar.FunctionalExtensionality noeq type t (key: eqtype) (value: (key -> Type)) = { mappings:F.restricted_t key value } let create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) : Tot (t key value) = { mappings = F.on_domain key f } let sel (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) : Tot (value k) = m.mappings k let sel_create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) (k: key) : Lemma (requires True) (ensures (sel #key #value (create f) k == f k)) [SMTPat (sel #key #value (create f) k)] = () let upd (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) : Tot (t key value) = { mappings = F.on_domain key (fun k' -> if k' = k then v else m.mappings k') } let sel_upd_same (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) = () let sel_upd_other (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) (k': key) = () let equal (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = forall k. sel m1 k == sel m2 k let equal_intro (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = () let equal_refl (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) = () let equal_elim (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = F.extensionality key value m1.mappings m2.mappings let restrict (#key: eqtype) (#value: (key -> Tot Type)) (p: (key -> Tot Type0)) (m: t key value) = { mappings = F.on_domain (k: key{p k}) m.mappings } let sel_restrict (#key: eqtype) (#value: (key -> Tot Type)) (p: (key -> Tot Type0)) (m: t key value) (k: key{p k}) = () let concat_mappings (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: (k1: key1 -> Tot (value1 k1))) (m2: (k2: key2 -> Tot (value2 k2))) (k: either key1 key2) : concat_value value1 value2 k = match k with | Inl k1 -> m1 k1 | Inr k2 -> m2 k2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.DependentMap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m1: FStar.DependentMap.t key1 value1 -> m2: FStar.DependentMap.t key2 value2 -> FStar.DependentMap.t (FStar.Pervasives.either key1 key2) (FStar.DependentMap.concat_value value1 value2)
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "FStar.DependentMap.t", "FStar.DependentMap.Mkt", "FStar.Pervasives.either", "FStar.DependentMap.concat_value", "FStar.FunctionalExtensionality.on_domain", "FStar.DependentMap.concat_mappings", "FStar.DependentMap.__proj__Mkt__item__mappings" ]
[]
false
false
false
false
false
let concat (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: t key1 value1) (m2: t key2 value2) : Tot (t (either key1 key2) (concat_value value1 value2)) =
{ mappings = F.on_domain (either key1 key2) (concat_mappings m1.mappings m2.mappings) }
false
FStar.DependentMap.fst
FStar.DependentMap.map
val map (#key: eqtype) (#value1 #value2: (key -> Tot Type)) (f: (k: key -> value1 k -> Tot (value2 k))) (m: t key value1) : Tot (t key value2)
val map (#key: eqtype) (#value1 #value2: (key -> Tot Type)) (f: (k: key -> value1 k -> Tot (value2 k))) (m: t key value1) : Tot (t key value2)
let map (#key: eqtype) (#value1 #value2: (key -> Tot Type)) (f: (k: key -> value1 k -> Tot (value2 k))) (m: t key value1) : Tot (t key value2) = { mappings = F.on_domain key (fun k -> f k (sel m k)) }
{ "file_name": "ulib/FStar.DependentMap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 82, "end_line": 137, "start_col": 0, "start_line": 132 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DependentMap module F = FStar.FunctionalExtensionality noeq type t (key: eqtype) (value: (key -> Type)) = { mappings:F.restricted_t key value } let create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) : Tot (t key value) = { mappings = F.on_domain key f } let sel (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) : Tot (value k) = m.mappings k let sel_create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) (k: key) : Lemma (requires True) (ensures (sel #key #value (create f) k == f k)) [SMTPat (sel #key #value (create f) k)] = () let upd (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) : Tot (t key value) = { mappings = F.on_domain key (fun k' -> if k' = k then v else m.mappings k') } let sel_upd_same (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) = () let sel_upd_other (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) (k': key) = () let equal (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = forall k. sel m1 k == sel m2 k let equal_intro (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = () let equal_refl (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) = () let equal_elim (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = F.extensionality key value m1.mappings m2.mappings let restrict (#key: eqtype) (#value: (key -> Tot Type)) (p: (key -> Tot Type0)) (m: t key value) = { mappings = F.on_domain (k: key{p k}) m.mappings } let sel_restrict (#key: eqtype) (#value: (key -> Tot Type)) (p: (key -> Tot Type0)) (m: t key value) (k: key{p k}) = () let concat_mappings (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: (k1: key1 -> Tot (value1 k1))) (m2: (k2: key2 -> Tot (value2 k2))) (k: either key1 key2) : concat_value value1 value2 k = match k with | Inl k1 -> m1 k1 | Inr k2 -> m2 k2 let concat (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: t key1 value1) (m2: t key2 value2) : Tot (t (either key1 key2) (concat_value value1 value2)) = { mappings = F.on_domain (either key1 key2) (concat_mappings m1.mappings m2.mappings) } let sel_concat_l (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: t key1 value1) (m2: t key2 value2) (k1: key1) = () let sel_concat_r (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: t key1 value1) (m2: t key2 value2) (k2: key2) = () let rename (#key1: eqtype) (#value1: (key1 -> Tot Type)) (m: t key1 value1) (#key2: eqtype) (ren: (key2 -> Tot key1)) : Tot (t key2 (rename_value value1 ren)) = { mappings = F.on_domain key2 (fun k2 -> m.mappings (ren k2)) } let sel_rename (#key1: eqtype) (#value1: (key1 -> Tot Type)) (m: t key1 value1) (#key2: eqtype) (ren: (key2 -> Tot key1)) (k2: key2) : Lemma (ensures (sel (rename m ren) k2 == sel m (ren k2))) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.DependentMap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (k: key -> _: value1 k -> value2 k) -> m: FStar.DependentMap.t key value1 -> FStar.DependentMap.t key value2
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "FStar.DependentMap.t", "FStar.DependentMap.Mkt", "FStar.FunctionalExtensionality.on_domain", "FStar.DependentMap.sel" ]
[]
false
false
false
false
false
let map (#key: eqtype) (#value1 #value2: (key -> Tot Type)) (f: (k: key -> value1 k -> Tot (value2 k))) (m: t key value1) : Tot (t key value2) =
{ mappings = F.on_domain key (fun k -> f k (sel m k)) }
false
FStar.DependentMap.fst
FStar.DependentMap.map_upd
val map_upd (#key: eqtype) (#value1 #value2: (key -> Tot Type)) (f: (k: key -> value1 k -> Tot (value2 k))) (m: t key value1) (k: key) (v: value1 k) : Lemma (ensures (map f (upd m k v) == upd (map f m) k (f k v))) [ //AR: wanted to write an SMTPatOr, but gives some error SMTPat (map #key #value1 #value2 f (upd #key #value1 m k v)) ]
val map_upd (#key: eqtype) (#value1 #value2: (key -> Tot Type)) (f: (k: key -> value1 k -> Tot (value2 k))) (m: t key value1) (k: key) (v: value1 k) : Lemma (ensures (map f (upd m k v) == upd (map f m) k (f k v))) [ //AR: wanted to write an SMTPatOr, but gives some error SMTPat (map #key #value1 #value2 f (upd #key #value1 m k v)) ]
let map_upd (#key: eqtype) (#value1 #value2: (key -> Tot Type)) (f: (k: key -> value1 k -> Tot (value2 k))) (m: t key value1) (k: key) (v: value1 k) = equal_elim #key #value2 (map f (upd m k v)) (upd (map f m) k (f k v))
{ "file_name": "ulib/FStar.DependentMap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 76, "end_line": 154, "start_col": 0, "start_line": 147 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DependentMap module F = FStar.FunctionalExtensionality noeq type t (key: eqtype) (value: (key -> Type)) = { mappings:F.restricted_t key value } let create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) : Tot (t key value) = { mappings = F.on_domain key f } let sel (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) : Tot (value k) = m.mappings k let sel_create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) (k: key) : Lemma (requires True) (ensures (sel #key #value (create f) k == f k)) [SMTPat (sel #key #value (create f) k)] = () let upd (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) : Tot (t key value) = { mappings = F.on_domain key (fun k' -> if k' = k then v else m.mappings k') } let sel_upd_same (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) = () let sel_upd_other (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) (k': key) = () let equal (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = forall k. sel m1 k == sel m2 k let equal_intro (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = () let equal_refl (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) = () let equal_elim (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = F.extensionality key value m1.mappings m2.mappings let restrict (#key: eqtype) (#value: (key -> Tot Type)) (p: (key -> Tot Type0)) (m: t key value) = { mappings = F.on_domain (k: key{p k}) m.mappings } let sel_restrict (#key: eqtype) (#value: (key -> Tot Type)) (p: (key -> Tot Type0)) (m: t key value) (k: key{p k}) = () let concat_mappings (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: (k1: key1 -> Tot (value1 k1))) (m2: (k2: key2 -> Tot (value2 k2))) (k: either key1 key2) : concat_value value1 value2 k = match k with | Inl k1 -> m1 k1 | Inr k2 -> m2 k2 let concat (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: t key1 value1) (m2: t key2 value2) : Tot (t (either key1 key2) (concat_value value1 value2)) = { mappings = F.on_domain (either key1 key2) (concat_mappings m1.mappings m2.mappings) } let sel_concat_l (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: t key1 value1) (m2: t key2 value2) (k1: key1) = () let sel_concat_r (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: t key1 value1) (m2: t key2 value2) (k2: key2) = () let rename (#key1: eqtype) (#value1: (key1 -> Tot Type)) (m: t key1 value1) (#key2: eqtype) (ren: (key2 -> Tot key1)) : Tot (t key2 (rename_value value1 ren)) = { mappings = F.on_domain key2 (fun k2 -> m.mappings (ren k2)) } let sel_rename (#key1: eqtype) (#value1: (key1 -> Tot Type)) (m: t key1 value1) (#key2: eqtype) (ren: (key2 -> Tot key1)) (k2: key2) : Lemma (ensures (sel (rename m ren) k2 == sel m (ren k2))) = () let map (#key: eqtype) (#value1 #value2: (key -> Tot Type)) (f: (k: key -> value1 k -> Tot (value2 k))) (m: t key value1) : Tot (t key value2) = { mappings = F.on_domain key (fun k -> f k (sel m k)) } let sel_map (#key: eqtype) (#value1 #value2: (key -> Tot Type)) (f: (k: key -> value1 k -> Tot (value2 k))) (m: t key value1) (k: key) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.DependentMap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (k: key -> _: value1 k -> value2 k) -> m: FStar.DependentMap.t key value1 -> k: key -> v: value1 k -> FStar.Pervasives.Lemma (ensures FStar.DependentMap.map f (FStar.DependentMap.upd m k v) == FStar.DependentMap.upd (FStar.DependentMap.map f m) k (f k v)) [SMTPat (FStar.DependentMap.map f (FStar.DependentMap.upd m k v))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "FStar.DependentMap.t", "FStar.DependentMap.equal_elim", "FStar.DependentMap.map", "FStar.DependentMap.upd", "Prims.unit" ]
[]
true
false
true
false
false
let map_upd (#key: eqtype) (#value1 #value2: (key -> Tot Type)) (f: (k: key -> value1 k -> Tot (value2 k))) (m: t key value1) (k: key) (v: value1 k) =
equal_elim #key #value2 (map f (upd m k v)) (upd (map f m) k (f k v))
false
FStar.DependentMap.fst
FStar.DependentMap.rename
val rename (#key1: eqtype) (#value1: (key1 -> Tot Type)) (m: t key1 value1) (#key2: eqtype) (ren: (key2 -> Tot key1)) : Tot (t key2 (rename_value value1 ren))
val rename (#key1: eqtype) (#value1: (key1 -> Tot Type)) (m: t key1 value1) (#key2: eqtype) (ren: (key2 -> Tot key1)) : Tot (t key2 (rename_value value1 ren))
let rename (#key1: eqtype) (#value1: (key1 -> Tot Type)) (m: t key1 value1) (#key2: eqtype) (ren: (key2 -> Tot key1)) : Tot (t key2 (rename_value value1 ren)) = { mappings = F.on_domain key2 (fun k2 -> m.mappings (ren k2)) }
{ "file_name": "ulib/FStar.DependentMap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 65, "end_line": 121, "start_col": 0, "start_line": 114 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DependentMap module F = FStar.FunctionalExtensionality noeq type t (key: eqtype) (value: (key -> Type)) = { mappings:F.restricted_t key value } let create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) : Tot (t key value) = { mappings = F.on_domain key f } let sel (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) : Tot (value k) = m.mappings k let sel_create (#key: eqtype) (#value: (key -> Tot Type)) (f: (k: key -> Tot (value k))) (k: key) : Lemma (requires True) (ensures (sel #key #value (create f) k == f k)) [SMTPat (sel #key #value (create f) k)] = () let upd (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) : Tot (t key value) = { mappings = F.on_domain key (fun k' -> if k' = k then v else m.mappings k') } let sel_upd_same (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) = () let sel_upd_other (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) (k: key) (v: value k) (k': key) = () let equal (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = forall k. sel m1 k == sel m2 k let equal_intro (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = () let equal_refl (#key: eqtype) (#value: (key -> Tot Type)) (m: t key value) = () let equal_elim (#key: eqtype) (#value: (key -> Tot Type)) (m1 m2: t key value) = F.extensionality key value m1.mappings m2.mappings let restrict (#key: eqtype) (#value: (key -> Tot Type)) (p: (key -> Tot Type0)) (m: t key value) = { mappings = F.on_domain (k: key{p k}) m.mappings } let sel_restrict (#key: eqtype) (#value: (key -> Tot Type)) (p: (key -> Tot Type0)) (m: t key value) (k: key{p k}) = () let concat_mappings (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: (k1: key1 -> Tot (value1 k1))) (m2: (k2: key2 -> Tot (value2 k2))) (k: either key1 key2) : concat_value value1 value2 k = match k with | Inl k1 -> m1 k1 | Inr k2 -> m2 k2 let concat (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: t key1 value1) (m2: t key2 value2) : Tot (t (either key1 key2) (concat_value value1 value2)) = { mappings = F.on_domain (either key1 key2) (concat_mappings m1.mappings m2.mappings) } let sel_concat_l (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: t key1 value1) (m2: t key2 value2) (k1: key1) = () let sel_concat_r (#key1: eqtype) (#value1: (key1 -> Tot Type)) (#key2: eqtype) (#value2: (key2 -> Tot Type)) (m1: t key1 value1) (m2: t key2 value2) (k2: key2) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.DependentMap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.DependentMap.t key1 value1 -> ren: (_: key2 -> key1) -> FStar.DependentMap.t key2 (FStar.DependentMap.rename_value value1 ren)
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "FStar.DependentMap.t", "FStar.DependentMap.Mkt", "FStar.FunctionalExtensionality.on_domain", "FStar.DependentMap.__proj__Mkt__item__mappings", "FStar.DependentMap.rename_value" ]
[]
false
false
false
false
false
let rename (#key1: eqtype) (#value1: (key1 -> Tot Type)) (m: t key1 value1) (#key2: eqtype) (ren: (key2 -> Tot key1)) : Tot (t key2 (rename_value value1 ren)) =
{ mappings = F.on_domain key2 (fun k2 -> m.mappings (ren k2)) }
false
FStar.Math.Lib.fst
FStar.Math.Lib.shift_left
val shift_left: v:int -> i:nat -> Tot (res:int{res = v * (pow2 i)})
val shift_left: v:int -> i:nat -> Tot (res:int{res = v * (pow2 i)})
let shift_left v i = v * (pow2 i)
{ "file_name": "ulib/FStar.Math.Lib.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 14, "end_line": 97, "start_col": 0, "start_line": 96 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Math.Lib open FStar.Mul (* Definition of the division operator *) val lemma_div_def: a:nat -> b:pos -> Lemma (a = b * (a/b) + a % b) let lemma_div_def a b = () private let mul_lemma (a:nat) (b:nat) (c:nat) : Lemma (requires (a <= b)) (ensures (c * a <= c * b)) = () private let mul_lemma' (a:nat) (b:nat) (c:pos) : Lemma (requires (c * a <= c * b)) (ensures (a <= b)) = () private let mul_div_lemma (a:nat) (b:pos) : Lemma (b * (a / b) <= a) = () val slash_decr_axiom: a:nat -> b:pos -> Lemma (a / b <= a) let slash_decr_axiom a b = mul_lemma 1 b a; mul_div_lemma a b; mul_lemma' (a / b) a b private let lemma_mul_minus_distr_l (a:int) (b:int) (c:int) : Lemma (a * (b - c) = a * b - a * c) = () (* Axiom: definition of the "b divides c" relation *) #reset-options "--z3rlimit 30" val slash_star_axiom: a:nat -> b:pos -> c:nat -> Lemma (requires (a * b = c)) (ensures (a = c / b)) let slash_star_axiom a b c = lemma_div_def c b; lemma_mul_minus_distr_l b a (c/b) #reset-options val log_2: x:pos -> Tot nat let rec log_2 x = if x >= 2 then 1 + log_2 (x / 2) else 0 (* Function: power of x *) val powx : x:int -> n:nat -> Tot int let rec powx x n = match n with | 0 -> 1 | n -> x * powx x (n - 1) (* Function: absolute value *) val abs: x:int -> Tot (y:int{ (x >= 0 ==> y = x) /\ (x < 0 ==> y = -x) }) let abs x = if x >= 0 then x else -x (* Function: maximum value *) val max: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = x) /\ (x < y ==> z = y) }) let max x y = if x >= y then x else y (* Function: minimum value *) val min: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = y) /\ (x < y ==> z = x) }) let min x y = if x >= y then y else x (* Function: standard euclidean division, the rest is always positive *) val div: a:int -> b:pos -> Tot (c:int{(a < 0 ==> c < 0) /\ (a >= 0 ==> c >= 0)}) let div a b = if a < 0 then begin slash_decr_axiom (-a) b; if a % b = 0 then - (-a / b) else - (-a / b) - 1 end else a / b (* Function: equivalent of the '/' operator in C, hence the rest can be negative *) val div_non_eucl: a:int -> b:pos -> Tot (q:int{ ( a >= 0 ==> q = a / b ) /\ ( a < 0 ==> q = -((-a)/b) ) }) let div_non_eucl a b = if a < 0 then 0 - ((0 - a) / b) else a / b (* The equivalent of the << C operator *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Math.Lib.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
v: Prims.int -> i: Prims.nat -> res: Prims.int{res = v * Prims.pow2 i}
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.nat", "FStar.Mul.op_Star", "Prims.pow2", "Prims.b2t", "Prims.op_Equality" ]
[]
false
false
false
false
false
let shift_left v i =
v * (pow2 i)
false
FStar.Math.Lib.fst
FStar.Math.Lib.arithmetic_shift_right
val arithmetic_shift_right: v:int -> i:nat -> Tot (res:int{ res = div v (pow2 i) })
val arithmetic_shift_right: v:int -> i:nat -> Tot (res:int{ res = div v (pow2 i) })
let arithmetic_shift_right v i = div v (pow2 i)
{ "file_name": "ulib/FStar.Math.Lib.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 16, "end_line": 102, "start_col": 0, "start_line": 101 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Math.Lib open FStar.Mul (* Definition of the division operator *) val lemma_div_def: a:nat -> b:pos -> Lemma (a = b * (a/b) + a % b) let lemma_div_def a b = () private let mul_lemma (a:nat) (b:nat) (c:nat) : Lemma (requires (a <= b)) (ensures (c * a <= c * b)) = () private let mul_lemma' (a:nat) (b:nat) (c:pos) : Lemma (requires (c * a <= c * b)) (ensures (a <= b)) = () private let mul_div_lemma (a:nat) (b:pos) : Lemma (b * (a / b) <= a) = () val slash_decr_axiom: a:nat -> b:pos -> Lemma (a / b <= a) let slash_decr_axiom a b = mul_lemma 1 b a; mul_div_lemma a b; mul_lemma' (a / b) a b private let lemma_mul_minus_distr_l (a:int) (b:int) (c:int) : Lemma (a * (b - c) = a * b - a * c) = () (* Axiom: definition of the "b divides c" relation *) #reset-options "--z3rlimit 30" val slash_star_axiom: a:nat -> b:pos -> c:nat -> Lemma (requires (a * b = c)) (ensures (a = c / b)) let slash_star_axiom a b c = lemma_div_def c b; lemma_mul_minus_distr_l b a (c/b) #reset-options val log_2: x:pos -> Tot nat let rec log_2 x = if x >= 2 then 1 + log_2 (x / 2) else 0 (* Function: power of x *) val powx : x:int -> n:nat -> Tot int let rec powx x n = match n with | 0 -> 1 | n -> x * powx x (n - 1) (* Function: absolute value *) val abs: x:int -> Tot (y:int{ (x >= 0 ==> y = x) /\ (x < 0 ==> y = -x) }) let abs x = if x >= 0 then x else -x (* Function: maximum value *) val max: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = x) /\ (x < y ==> z = y) }) let max x y = if x >= y then x else y (* Function: minimum value *) val min: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = y) /\ (x < y ==> z = x) }) let min x y = if x >= y then y else x (* Function: standard euclidean division, the rest is always positive *) val div: a:int -> b:pos -> Tot (c:int{(a < 0 ==> c < 0) /\ (a >= 0 ==> c >= 0)}) let div a b = if a < 0 then begin slash_decr_axiom (-a) b; if a % b = 0 then - (-a / b) else - (-a / b) - 1 end else a / b (* Function: equivalent of the '/' operator in C, hence the rest can be negative *) val div_non_eucl: a:int -> b:pos -> Tot (q:int{ ( a >= 0 ==> q = a / b ) /\ ( a < 0 ==> q = -((-a)/b) ) }) let div_non_eucl a b = if a < 0 then 0 - ((0 - a) / b) else a / b (* The equivalent of the << C operator *) val shift_left: v:int -> i:nat -> Tot (res:int{res = v * (pow2 i)}) let shift_left v i = v * (pow2 i) (* asr OCaml operator *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Math.Lib.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
v: Prims.int -> i: Prims.nat -> res: Prims.int{res = FStar.Math.Lib.div v (Prims.pow2 i)}
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.nat", "FStar.Math.Lib.div", "Prims.pow2", "Prims.b2t", "Prims.op_Equality" ]
[]
false
false
false
false
false
let arithmetic_shift_right v i =
div v (pow2 i)
false
FStar.Math.Lib.fst
FStar.Math.Lib.max
val max: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = x) /\ (x < y ==> z = y) })
val max: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = x) /\ (x < y ==> z = y) })
let max x y = if x >= y then x else y
{ "file_name": "ulib/FStar.Math.Lib.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 70, "start_col": 0, "start_line": 70 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Math.Lib open FStar.Mul (* Definition of the division operator *) val lemma_div_def: a:nat -> b:pos -> Lemma (a = b * (a/b) + a % b) let lemma_div_def a b = () private let mul_lemma (a:nat) (b:nat) (c:nat) : Lemma (requires (a <= b)) (ensures (c * a <= c * b)) = () private let mul_lemma' (a:nat) (b:nat) (c:pos) : Lemma (requires (c * a <= c * b)) (ensures (a <= b)) = () private let mul_div_lemma (a:nat) (b:pos) : Lemma (b * (a / b) <= a) = () val slash_decr_axiom: a:nat -> b:pos -> Lemma (a / b <= a) let slash_decr_axiom a b = mul_lemma 1 b a; mul_div_lemma a b; mul_lemma' (a / b) a b private let lemma_mul_minus_distr_l (a:int) (b:int) (c:int) : Lemma (a * (b - c) = a * b - a * c) = () (* Axiom: definition of the "b divides c" relation *) #reset-options "--z3rlimit 30" val slash_star_axiom: a:nat -> b:pos -> c:nat -> Lemma (requires (a * b = c)) (ensures (a = c / b)) let slash_star_axiom a b c = lemma_div_def c b; lemma_mul_minus_distr_l b a (c/b) #reset-options val log_2: x:pos -> Tot nat let rec log_2 x = if x >= 2 then 1 + log_2 (x / 2) else 0 (* Function: power of x *) val powx : x:int -> n:nat -> Tot int let rec powx x n = match n with | 0 -> 1 | n -> x * powx x (n - 1) (* Function: absolute value *) val abs: x:int -> Tot (y:int{ (x >= 0 ==> y = x) /\ (x < 0 ==> y = -x) }) let abs x = if x >= 0 then x else -x (* Function: maximum value *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Math.Lib.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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.int -> y: Prims.int -> z: Prims.int{(x >= y ==> z = x) /\ (x < y ==> z = y)}
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.op_GreaterThanOrEqual", "Prims.bool", "Prims.l_and", "Prims.l_imp", "Prims.b2t", "Prims.op_Equality", "Prims.op_LessThan" ]
[]
false
false
false
false
false
let max x y =
if x >= y then x else y
false
FStar.Math.Lib.fst
FStar.Math.Lib.powx
val powx : x:int -> n:nat -> Tot int
val powx : x:int -> n:nat -> Tot int
let rec powx x n = match n with | 0 -> 1 | n -> x * powx x (n - 1)
{ "file_name": "ulib/FStar.Math.Lib.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 62, "start_col": 0, "start_line": 59 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Math.Lib open FStar.Mul (* Definition of the division operator *) val lemma_div_def: a:nat -> b:pos -> Lemma (a = b * (a/b) + a % b) let lemma_div_def a b = () private let mul_lemma (a:nat) (b:nat) (c:nat) : Lemma (requires (a <= b)) (ensures (c * a <= c * b)) = () private let mul_lemma' (a:nat) (b:nat) (c:pos) : Lemma (requires (c * a <= c * b)) (ensures (a <= b)) = () private let mul_div_lemma (a:nat) (b:pos) : Lemma (b * (a / b) <= a) = () val slash_decr_axiom: a:nat -> b:pos -> Lemma (a / b <= a) let slash_decr_axiom a b = mul_lemma 1 b a; mul_div_lemma a b; mul_lemma' (a / b) a b private let lemma_mul_minus_distr_l (a:int) (b:int) (c:int) : Lemma (a * (b - c) = a * b - a * c) = () (* Axiom: definition of the "b divides c" relation *) #reset-options "--z3rlimit 30" val slash_star_axiom: a:nat -> b:pos -> c:nat -> Lemma (requires (a * b = c)) (ensures (a = c / b)) let slash_star_axiom a b c = lemma_div_def c b; lemma_mul_minus_distr_l b a (c/b) #reset-options val log_2: x:pos -> Tot nat let rec log_2 x = if x >= 2 then 1 + log_2 (x / 2) else 0 (* Function: power of x *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Math.Lib.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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.int -> n: Prims.nat -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.nat", "FStar.Mul.op_Star", "FStar.Math.Lib.powx", "Prims.op_Subtraction" ]
[ "recursion" ]
false
false
false
true
false
let rec powx x n =
match n with | 0 -> 1 | n -> x * powx x (n - 1)
false
FStar.Math.Lib.fst
FStar.Math.Lib.slash_decr_axiom
val slash_decr_axiom: a:nat -> b:pos -> Lemma (a / b <= a)
val slash_decr_axiom: a:nat -> b:pos -> Lemma (a / b <= a)
let slash_decr_axiom a b = mul_lemma 1 b a; mul_div_lemma a b; mul_lemma' (a / b) a b
{ "file_name": "ulib/FStar.Math.Lib.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 26, "end_line": 38, "start_col": 0, "start_line": 35 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Math.Lib open FStar.Mul (* Definition of the division operator *) val lemma_div_def: a:nat -> b:pos -> Lemma (a = b * (a/b) + a % b) let lemma_div_def a b = () private let mul_lemma (a:nat) (b:nat) (c:nat) : Lemma (requires (a <= b)) (ensures (c * a <= c * b)) = () private let mul_lemma' (a:nat) (b:nat) (c:pos) : Lemma (requires (c * a <= c * b)) (ensures (a <= b)) = () private let mul_div_lemma (a:nat) (b:pos) : Lemma (b * (a / b) <= a) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Math.Lib.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Prims.nat -> b: Prims.pos -> FStar.Pervasives.Lemma (ensures a / b <= a)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "Prims.pos", "FStar.Math.Lib.mul_lemma'", "Prims.op_Division", "Prims.unit", "FStar.Math.Lib.mul_div_lemma", "FStar.Math.Lib.mul_lemma" ]
[]
true
false
true
false
false
let slash_decr_axiom a b =
mul_lemma 1 b a; mul_div_lemma a b; mul_lemma' (a / b) a b
false
FStar.Math.Lib.fst
FStar.Math.Lib.log_2
val log_2: x:pos -> Tot nat
val log_2: x:pos -> Tot nat
let rec log_2 x = if x >= 2 then 1 + log_2 (x / 2) else 0
{ "file_name": "ulib/FStar.Math.Lib.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 41, "end_line": 55, "start_col": 0, "start_line": 54 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Math.Lib open FStar.Mul (* Definition of the division operator *) val lemma_div_def: a:nat -> b:pos -> Lemma (a = b * (a/b) + a % b) let lemma_div_def a b = () private let mul_lemma (a:nat) (b:nat) (c:nat) : Lemma (requires (a <= b)) (ensures (c * a <= c * b)) = () private let mul_lemma' (a:nat) (b:nat) (c:pos) : Lemma (requires (c * a <= c * b)) (ensures (a <= b)) = () private let mul_div_lemma (a:nat) (b:pos) : Lemma (b * (a / b) <= a) = () val slash_decr_axiom: a:nat -> b:pos -> Lemma (a / b <= a) let slash_decr_axiom a b = mul_lemma 1 b a; mul_div_lemma a b; mul_lemma' (a / b) a b private let lemma_mul_minus_distr_l (a:int) (b:int) (c:int) : Lemma (a * (b - c) = a * b - a * c) = () (* Axiom: definition of the "b divides c" relation *) #reset-options "--z3rlimit 30" val slash_star_axiom: a:nat -> b:pos -> c:nat -> Lemma (requires (a * b = c)) (ensures (a = c / b)) let slash_star_axiom a b c = lemma_div_def c b; lemma_mul_minus_distr_l b a (c/b) #reset-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Math.Lib.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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.pos -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.op_GreaterThanOrEqual", "Prims.op_Addition", "FStar.Math.Lib.log_2", "Prims.op_Division", "Prims.bool", "Prims.nat" ]
[ "recursion" ]
false
false
false
true
false
let rec log_2 x =
if x >= 2 then 1 + log_2 (x / 2) else 0
false
FStar.Math.Lib.fst
FStar.Math.Lib.abs
val abs: x:int -> Tot (y:int{ (x >= 0 ==> y = x) /\ (x < 0 ==> y = -x) })
val abs: x:int -> Tot (y:int{ (x >= 0 ==> y = x) /\ (x < 0 ==> y = -x) })
let abs x = if x >= 0 then x else -x
{ "file_name": "ulib/FStar.Math.Lib.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 36, "end_line": 66, "start_col": 0, "start_line": 66 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Math.Lib open FStar.Mul (* Definition of the division operator *) val lemma_div_def: a:nat -> b:pos -> Lemma (a = b * (a/b) + a % b) let lemma_div_def a b = () private let mul_lemma (a:nat) (b:nat) (c:nat) : Lemma (requires (a <= b)) (ensures (c * a <= c * b)) = () private let mul_lemma' (a:nat) (b:nat) (c:pos) : Lemma (requires (c * a <= c * b)) (ensures (a <= b)) = () private let mul_div_lemma (a:nat) (b:pos) : Lemma (b * (a / b) <= a) = () val slash_decr_axiom: a:nat -> b:pos -> Lemma (a / b <= a) let slash_decr_axiom a b = mul_lemma 1 b a; mul_div_lemma a b; mul_lemma' (a / b) a b private let lemma_mul_minus_distr_l (a:int) (b:int) (c:int) : Lemma (a * (b - c) = a * b - a * c) = () (* Axiom: definition of the "b divides c" relation *) #reset-options "--z3rlimit 30" val slash_star_axiom: a:nat -> b:pos -> c:nat -> Lemma (requires (a * b = c)) (ensures (a = c / b)) let slash_star_axiom a b c = lemma_div_def c b; lemma_mul_minus_distr_l b a (c/b) #reset-options val log_2: x:pos -> Tot nat let rec log_2 x = if x >= 2 then 1 + log_2 (x / 2) else 0 (* Function: power of x *) val powx : x:int -> n:nat -> Tot int let rec powx x n = match n with | 0 -> 1 | n -> x * powx x (n - 1) (* Function: absolute value *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Math.Lib.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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.int -> y: Prims.int{(x >= 0 ==> y = x) /\ (x < 0 ==> y = - x)}
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.op_GreaterThanOrEqual", "Prims.bool", "Prims.op_Minus", "Prims.l_and", "Prims.l_imp", "Prims.b2t", "Prims.op_Equality", "Prims.op_LessThan" ]
[]
false
false
false
false
false
let abs x =
if x >= 0 then x else - x
false
FStar.Math.Lib.fst
FStar.Math.Lib.min
val min: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = y) /\ (x < y ==> z = x) })
val min: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = y) /\ (x < y ==> z = x) })
let min x y = if x >= y then y else x
{ "file_name": "ulib/FStar.Math.Lib.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 74, "start_col": 0, "start_line": 74 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Math.Lib open FStar.Mul (* Definition of the division operator *) val lemma_div_def: a:nat -> b:pos -> Lemma (a = b * (a/b) + a % b) let lemma_div_def a b = () private let mul_lemma (a:nat) (b:nat) (c:nat) : Lemma (requires (a <= b)) (ensures (c * a <= c * b)) = () private let mul_lemma' (a:nat) (b:nat) (c:pos) : Lemma (requires (c * a <= c * b)) (ensures (a <= b)) = () private let mul_div_lemma (a:nat) (b:pos) : Lemma (b * (a / b) <= a) = () val slash_decr_axiom: a:nat -> b:pos -> Lemma (a / b <= a) let slash_decr_axiom a b = mul_lemma 1 b a; mul_div_lemma a b; mul_lemma' (a / b) a b private let lemma_mul_minus_distr_l (a:int) (b:int) (c:int) : Lemma (a * (b - c) = a * b - a * c) = () (* Axiom: definition of the "b divides c" relation *) #reset-options "--z3rlimit 30" val slash_star_axiom: a:nat -> b:pos -> c:nat -> Lemma (requires (a * b = c)) (ensures (a = c / b)) let slash_star_axiom a b c = lemma_div_def c b; lemma_mul_minus_distr_l b a (c/b) #reset-options val log_2: x:pos -> Tot nat let rec log_2 x = if x >= 2 then 1 + log_2 (x / 2) else 0 (* Function: power of x *) val powx : x:int -> n:nat -> Tot int let rec powx x n = match n with | 0 -> 1 | n -> x * powx x (n - 1) (* Function: absolute value *) val abs: x:int -> Tot (y:int{ (x >= 0 ==> y = x) /\ (x < 0 ==> y = -x) }) let abs x = if x >= 0 then x else -x (* Function: maximum value *) val max: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = x) /\ (x < y ==> z = y) }) let max x y = if x >= y then x else y (* Function: minimum value *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Math.Lib.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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.int -> y: Prims.int -> z: Prims.int{(x >= y ==> z = y) /\ (x < y ==> z = x)}
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.op_GreaterThanOrEqual", "Prims.bool", "Prims.l_and", "Prims.l_imp", "Prims.b2t", "Prims.op_Equality", "Prims.op_LessThan" ]
[]
false
false
false
false
false
let min x y =
if x >= y then y else x
false
FStar.Math.Lib.fst
FStar.Math.Lib.div_non_eucl
val div_non_eucl: a:int -> b:pos -> Tot (q:int{ ( a >= 0 ==> q = a / b ) /\ ( a < 0 ==> q = -((-a)/b) ) })
val div_non_eucl: a:int -> b:pos -> Tot (q:int{ ( a >= 0 ==> q = a / b ) /\ ( a < 0 ==> q = -((-a)/b) ) })
let div_non_eucl a b = if a < 0 then 0 - ((0 - a) / b) else a / b
{ "file_name": "ulib/FStar.Math.Lib.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 92, "start_col": 0, "start_line": 90 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Math.Lib open FStar.Mul (* Definition of the division operator *) val lemma_div_def: a:nat -> b:pos -> Lemma (a = b * (a/b) + a % b) let lemma_div_def a b = () private let mul_lemma (a:nat) (b:nat) (c:nat) : Lemma (requires (a <= b)) (ensures (c * a <= c * b)) = () private let mul_lemma' (a:nat) (b:nat) (c:pos) : Lemma (requires (c * a <= c * b)) (ensures (a <= b)) = () private let mul_div_lemma (a:nat) (b:pos) : Lemma (b * (a / b) <= a) = () val slash_decr_axiom: a:nat -> b:pos -> Lemma (a / b <= a) let slash_decr_axiom a b = mul_lemma 1 b a; mul_div_lemma a b; mul_lemma' (a / b) a b private let lemma_mul_minus_distr_l (a:int) (b:int) (c:int) : Lemma (a * (b - c) = a * b - a * c) = () (* Axiom: definition of the "b divides c" relation *) #reset-options "--z3rlimit 30" val slash_star_axiom: a:nat -> b:pos -> c:nat -> Lemma (requires (a * b = c)) (ensures (a = c / b)) let slash_star_axiom a b c = lemma_div_def c b; lemma_mul_minus_distr_l b a (c/b) #reset-options val log_2: x:pos -> Tot nat let rec log_2 x = if x >= 2 then 1 + log_2 (x / 2) else 0 (* Function: power of x *) val powx : x:int -> n:nat -> Tot int let rec powx x n = match n with | 0 -> 1 | n -> x * powx x (n - 1) (* Function: absolute value *) val abs: x:int -> Tot (y:int{ (x >= 0 ==> y = x) /\ (x < 0 ==> y = -x) }) let abs x = if x >= 0 then x else -x (* Function: maximum value *) val max: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = x) /\ (x < y ==> z = y) }) let max x y = if x >= y then x else y (* Function: minimum value *) val min: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = y) /\ (x < y ==> z = x) }) let min x y = if x >= y then y else x (* Function: standard euclidean division, the rest is always positive *) val div: a:int -> b:pos -> Tot (c:int{(a < 0 ==> c < 0) /\ (a >= 0 ==> c >= 0)}) let div a b = if a < 0 then begin slash_decr_axiom (-a) b; if a % b = 0 then - (-a / b) else - (-a / b) - 1 end else a / b (* Function: equivalent of the '/' operator in C, hence the rest can be negative *) val div_non_eucl: a:int -> b:pos ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Math.Lib.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Prims.int -> b: Prims.pos -> q: Prims.int{(a >= 0 ==> q = a / b) /\ (a < 0 ==> q = - (- a) / b)}
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.pos", "Prims.op_LessThan", "Prims.op_Subtraction", "Prims.op_Division", "Prims.bool", "Prims.l_and", "Prims.l_imp", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_Equality", "Prims.op_Minus" ]
[]
false
false
false
false
false
let div_non_eucl a b =
if a < 0 then 0 - ((0 - a) / b) else a / b
false
FStar.Math.Lib.fst
FStar.Math.Lib.div
val div: a:int -> b:pos -> Tot (c:int{(a < 0 ==> c < 0) /\ (a >= 0 ==> c >= 0)})
val div: a:int -> b:pos -> Tot (c:int{(a < 0 ==> c < 0) /\ (a >= 0 ==> c >= 0)})
let div a b = if a < 0 then begin slash_decr_axiom (-a) b; if a % b = 0 then - (-a / b) else - (-a / b) - 1 end else a / b
{ "file_name": "ulib/FStar.Math.Lib.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 85, "start_col": 0, "start_line": 78 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Math.Lib open FStar.Mul (* Definition of the division operator *) val lemma_div_def: a:nat -> b:pos -> Lemma (a = b * (a/b) + a % b) let lemma_div_def a b = () private let mul_lemma (a:nat) (b:nat) (c:nat) : Lemma (requires (a <= b)) (ensures (c * a <= c * b)) = () private let mul_lemma' (a:nat) (b:nat) (c:pos) : Lemma (requires (c * a <= c * b)) (ensures (a <= b)) = () private let mul_div_lemma (a:nat) (b:pos) : Lemma (b * (a / b) <= a) = () val slash_decr_axiom: a:nat -> b:pos -> Lemma (a / b <= a) let slash_decr_axiom a b = mul_lemma 1 b a; mul_div_lemma a b; mul_lemma' (a / b) a b private let lemma_mul_minus_distr_l (a:int) (b:int) (c:int) : Lemma (a * (b - c) = a * b - a * c) = () (* Axiom: definition of the "b divides c" relation *) #reset-options "--z3rlimit 30" val slash_star_axiom: a:nat -> b:pos -> c:nat -> Lemma (requires (a * b = c)) (ensures (a = c / b)) let slash_star_axiom a b c = lemma_div_def c b; lemma_mul_minus_distr_l b a (c/b) #reset-options val log_2: x:pos -> Tot nat let rec log_2 x = if x >= 2 then 1 + log_2 (x / 2) else 0 (* Function: power of x *) val powx : x:int -> n:nat -> Tot int let rec powx x n = match n with | 0 -> 1 | n -> x * powx x (n - 1) (* Function: absolute value *) val abs: x:int -> Tot (y:int{ (x >= 0 ==> y = x) /\ (x < 0 ==> y = -x) }) let abs x = if x >= 0 then x else -x (* Function: maximum value *) val max: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = x) /\ (x < y ==> z = y) }) let max x y = if x >= y then x else y (* Function: minimum value *) val min: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = y) /\ (x < y ==> z = x) }) let min x y = if x >= y then y else x (* Function: standard euclidean division, the rest is always positive *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Math.Lib.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Prims.int -> b: Prims.pos -> c: Prims.int{(a < 0 ==> c < 0) /\ (a >= 0 ==> c >= 0)}
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.pos", "Prims.op_LessThan", "Prims.op_Equality", "Prims.op_Modulus", "Prims.op_Minus", "Prims.op_Division", "Prims.bool", "Prims.op_Subtraction", "Prims.l_and", "Prims.l_imp", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.unit", "FStar.Math.Lib.slash_decr_axiom" ]
[]
false
false
false
false
false
let div a b =
if a < 0 then (slash_decr_axiom (- a) b; if a % b = 0 then - (- a / b) else - (- a / b) - 1) else a / b
false
Version.fst
Version.everparse_version
val everparse_version : string
val everparse_version : string
let everparse_version = "00217c4a (unreleased)"
{ "file_name": "src/3d/Version.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 47, "end_line": 2, "start_col": 0, "start_line": 2 }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Version.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.string
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
false
let everparse_version =
"00217c4a (unreleased)"
false
Version.fst
Version.fstar_commit
val fstar_commit : string
val fstar_commit : string
let fstar_commit = "10183ea187"
{ "file_name": "src/3d/Version.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 31, "end_line": 3, "start_col": 0, "start_line": 3 }
module Version
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Version.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.string
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
false
let fstar_commit =
"10183ea187"
false
Version.fst
Version.karamel_commit
val karamel_commit : string
val karamel_commit : string
let karamel_commit = "da1e941b"
{ "file_name": "src/3d/Version.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 31, "end_line": 4, "start_col": 0, "start_line": 4 }
module Version let everparse_version = "00217c4a (unreleased)"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Version.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.string
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
false
let karamel_commit =
"da1e941b"
false
FStar.Math.Lib.fst
FStar.Math.Lib.powx_lemma2
val powx_lemma2: x:int -> n:nat -> m:nat -> Lemma (powx x n * powx x m = powx x (n + m))
val powx_lemma2: x:int -> n:nat -> m:nat -> Lemma (powx x n * powx x m = powx x (n + m))
let rec powx_lemma2 x n m = let ass (x y z : int) : Lemma ((x*y)*z == x*(y*z)) = () in match n with | 0 -> () | _ -> powx_lemma2 x (n-1) m; ass x (powx x (n-1)) (powx x m)
{ "file_name": "ulib/FStar.Math.Lib.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 63, "end_line": 127, "start_col": 0, "start_line": 123 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Math.Lib open FStar.Mul (* Definition of the division operator *) val lemma_div_def: a:nat -> b:pos -> Lemma (a = b * (a/b) + a % b) let lemma_div_def a b = () private let mul_lemma (a:nat) (b:nat) (c:nat) : Lemma (requires (a <= b)) (ensures (c * a <= c * b)) = () private let mul_lemma' (a:nat) (b:nat) (c:pos) : Lemma (requires (c * a <= c * b)) (ensures (a <= b)) = () private let mul_div_lemma (a:nat) (b:pos) : Lemma (b * (a / b) <= a) = () val slash_decr_axiom: a:nat -> b:pos -> Lemma (a / b <= a) let slash_decr_axiom a b = mul_lemma 1 b a; mul_div_lemma a b; mul_lemma' (a / b) a b private let lemma_mul_minus_distr_l (a:int) (b:int) (c:int) : Lemma (a * (b - c) = a * b - a * c) = () (* Axiom: definition of the "b divides c" relation *) #reset-options "--z3rlimit 30" val slash_star_axiom: a:nat -> b:pos -> c:nat -> Lemma (requires (a * b = c)) (ensures (a = c / b)) let slash_star_axiom a b c = lemma_div_def c b; lemma_mul_minus_distr_l b a (c/b) #reset-options val log_2: x:pos -> Tot nat let rec log_2 x = if x >= 2 then 1 + log_2 (x / 2) else 0 (* Function: power of x *) val powx : x:int -> n:nat -> Tot int let rec powx x n = match n with | 0 -> 1 | n -> x * powx x (n - 1) (* Function: absolute value *) val abs: x:int -> Tot (y:int{ (x >= 0 ==> y = x) /\ (x < 0 ==> y = -x) }) let abs x = if x >= 0 then x else -x (* Function: maximum value *) val max: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = x) /\ (x < y ==> z = y) }) let max x y = if x >= y then x else y (* Function: minimum value *) val min: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = y) /\ (x < y ==> z = x) }) let min x y = if x >= y then y else x (* Function: standard euclidean division, the rest is always positive *) val div: a:int -> b:pos -> Tot (c:int{(a < 0 ==> c < 0) /\ (a >= 0 ==> c >= 0)}) let div a b = if a < 0 then begin slash_decr_axiom (-a) b; if a % b = 0 then - (-a / b) else - (-a / b) - 1 end else a / b (* Function: equivalent of the '/' operator in C, hence the rest can be negative *) val div_non_eucl: a:int -> b:pos -> Tot (q:int{ ( a >= 0 ==> q = a / b ) /\ ( a < 0 ==> q = -((-a)/b) ) }) let div_non_eucl a b = if a < 0 then 0 - ((0 - a) / b) else a / b (* The equivalent of the << C operator *) val shift_left: v:int -> i:nat -> Tot (res:int{res = v * (pow2 i)}) let shift_left v i = v * (pow2 i) (* asr OCaml operator *) val arithmetic_shift_right: v:int -> i:nat -> Tot (res:int{ res = div v (pow2 i) }) let arithmetic_shift_right v i = div v (pow2 i) (* Case of C cast functions ? *) (* Implemented by "mod" in OCaml *) val signed_modulo: v:int -> p:pos -> Tot (res:int{ res = v - ((div_non_eucl v p) * p) }) let signed_modulo v p = if v >= 0 then v % p else 0 - ( (0-v) % p) val op_Plus_Percent : a:int -> p:pos -> Tot (res:int{ (a >= 0 ==> res = a % p) /\ (a < 0 ==> res = -((-a) % p)) }) let op_Plus_Percent a p = signed_modulo a p (** Useful lemmas for future proofs **) (* Lemmas of x^n *) val powx_lemma1: a:int -> Lemma (powx a 1 = a) let powx_lemma1 a = () val powx_lemma2: x:int -> n:nat -> m:nat -> Lemma
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Math.Lib.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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.int -> n: Prims.nat -> m: Prims.nat -> FStar.Pervasives.Lemma (ensures FStar.Math.Lib.powx x n * FStar.Math.Lib.powx x m = FStar.Math.Lib.powx x (n + m))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Prims.nat", "FStar.Math.Lib.powx", "Prims.op_Subtraction", "Prims.unit", "FStar.Math.Lib.powx_lemma2", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.op_Multiply", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Mul.op_Star" ]
[ "recursion" ]
false
false
true
false
false
let rec powx_lemma2 x n m =
let ass (x y z: int) : Lemma ((x * y) * z == x * (y * z)) = () in match n with | 0 -> () | _ -> powx_lemma2 x (n - 1) m; ass x (powx x (n - 1)) (powx x m)
false
FStar.Math.Lib.fst
FStar.Math.Lib.op_Plus_Percent
val op_Plus_Percent : a:int -> p:pos -> Tot (res:int{ (a >= 0 ==> res = a % p) /\ (a < 0 ==> res = -((-a) % p)) })
val op_Plus_Percent : a:int -> p:pos -> Tot (res:int{ (a >= 0 ==> res = a % p) /\ (a < 0 ==> res = -((-a) % p)) })
let op_Plus_Percent a p = signed_modulo a p
{ "file_name": "ulib/FStar.Math.Lib.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 113, "start_col": 0, "start_line": 113 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Math.Lib open FStar.Mul (* Definition of the division operator *) val lemma_div_def: a:nat -> b:pos -> Lemma (a = b * (a/b) + a % b) let lemma_div_def a b = () private let mul_lemma (a:nat) (b:nat) (c:nat) : Lemma (requires (a <= b)) (ensures (c * a <= c * b)) = () private let mul_lemma' (a:nat) (b:nat) (c:pos) : Lemma (requires (c * a <= c * b)) (ensures (a <= b)) = () private let mul_div_lemma (a:nat) (b:pos) : Lemma (b * (a / b) <= a) = () val slash_decr_axiom: a:nat -> b:pos -> Lemma (a / b <= a) let slash_decr_axiom a b = mul_lemma 1 b a; mul_div_lemma a b; mul_lemma' (a / b) a b private let lemma_mul_minus_distr_l (a:int) (b:int) (c:int) : Lemma (a * (b - c) = a * b - a * c) = () (* Axiom: definition of the "b divides c" relation *) #reset-options "--z3rlimit 30" val slash_star_axiom: a:nat -> b:pos -> c:nat -> Lemma (requires (a * b = c)) (ensures (a = c / b)) let slash_star_axiom a b c = lemma_div_def c b; lemma_mul_minus_distr_l b a (c/b) #reset-options val log_2: x:pos -> Tot nat let rec log_2 x = if x >= 2 then 1 + log_2 (x / 2) else 0 (* Function: power of x *) val powx : x:int -> n:nat -> Tot int let rec powx x n = match n with | 0 -> 1 | n -> x * powx x (n - 1) (* Function: absolute value *) val abs: x:int -> Tot (y:int{ (x >= 0 ==> y = x) /\ (x < 0 ==> y = -x) }) let abs x = if x >= 0 then x else -x (* Function: maximum value *) val max: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = x) /\ (x < y ==> z = y) }) let max x y = if x >= y then x else y (* Function: minimum value *) val min: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = y) /\ (x < y ==> z = x) }) let min x y = if x >= y then y else x (* Function: standard euclidean division, the rest is always positive *) val div: a:int -> b:pos -> Tot (c:int{(a < 0 ==> c < 0) /\ (a >= 0 ==> c >= 0)}) let div a b = if a < 0 then begin slash_decr_axiom (-a) b; if a % b = 0 then - (-a / b) else - (-a / b) - 1 end else a / b (* Function: equivalent of the '/' operator in C, hence the rest can be negative *) val div_non_eucl: a:int -> b:pos -> Tot (q:int{ ( a >= 0 ==> q = a / b ) /\ ( a < 0 ==> q = -((-a)/b) ) }) let div_non_eucl a b = if a < 0 then 0 - ((0 - a) / b) else a / b (* The equivalent of the << C operator *) val shift_left: v:int -> i:nat -> Tot (res:int{res = v * (pow2 i)}) let shift_left v i = v * (pow2 i) (* asr OCaml operator *) val arithmetic_shift_right: v:int -> i:nat -> Tot (res:int{ res = div v (pow2 i) }) let arithmetic_shift_right v i = div v (pow2 i) (* Case of C cast functions ? *) (* Implemented by "mod" in OCaml *) val signed_modulo: v:int -> p:pos -> Tot (res:int{ res = v - ((div_non_eucl v p) * p) }) let signed_modulo v p = if v >= 0 then v % p else 0 - ( (0-v) % p) val op_Plus_Percent : a:int -> p:pos ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Math.Lib.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Prims.int -> p: Prims.pos -> res: Prims.int{(a >= 0 ==> res = a % p) /\ (a < 0 ==> res = - (- a) % p)}
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.pos", "FStar.Math.Lib.signed_modulo", "Prims.l_and", "Prims.l_imp", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_Equality", "Prims.op_Modulus", "Prims.op_LessThan", "Prims.op_Minus" ]
[]
false
false
false
false
false
let ( +% ) a p =
signed_modulo a p
false
FStar.Math.Lib.fst
FStar.Math.Lib.signed_modulo
val signed_modulo: v:int -> p:pos -> Tot (res:int{ res = v - ((div_non_eucl v p) * p) })
val signed_modulo: v:int -> p:pos -> Tot (res:int{ res = v - ((div_non_eucl v p) * p) })
let signed_modulo v p = if v >= 0 then v % p else 0 - ( (0-v) % p)
{ "file_name": "ulib/FStar.Math.Lib.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 23, "end_line": 109, "start_col": 0, "start_line": 107 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Math.Lib open FStar.Mul (* Definition of the division operator *) val lemma_div_def: a:nat -> b:pos -> Lemma (a = b * (a/b) + a % b) let lemma_div_def a b = () private let mul_lemma (a:nat) (b:nat) (c:nat) : Lemma (requires (a <= b)) (ensures (c * a <= c * b)) = () private let mul_lemma' (a:nat) (b:nat) (c:pos) : Lemma (requires (c * a <= c * b)) (ensures (a <= b)) = () private let mul_div_lemma (a:nat) (b:pos) : Lemma (b * (a / b) <= a) = () val slash_decr_axiom: a:nat -> b:pos -> Lemma (a / b <= a) let slash_decr_axiom a b = mul_lemma 1 b a; mul_div_lemma a b; mul_lemma' (a / b) a b private let lemma_mul_minus_distr_l (a:int) (b:int) (c:int) : Lemma (a * (b - c) = a * b - a * c) = () (* Axiom: definition of the "b divides c" relation *) #reset-options "--z3rlimit 30" val slash_star_axiom: a:nat -> b:pos -> c:nat -> Lemma (requires (a * b = c)) (ensures (a = c / b)) let slash_star_axiom a b c = lemma_div_def c b; lemma_mul_minus_distr_l b a (c/b) #reset-options val log_2: x:pos -> Tot nat let rec log_2 x = if x >= 2 then 1 + log_2 (x / 2) else 0 (* Function: power of x *) val powx : x:int -> n:nat -> Tot int let rec powx x n = match n with | 0 -> 1 | n -> x * powx x (n - 1) (* Function: absolute value *) val abs: x:int -> Tot (y:int{ (x >= 0 ==> y = x) /\ (x < 0 ==> y = -x) }) let abs x = if x >= 0 then x else -x (* Function: maximum value *) val max: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = x) /\ (x < y ==> z = y) }) let max x y = if x >= y then x else y (* Function: minimum value *) val min: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = y) /\ (x < y ==> z = x) }) let min x y = if x >= y then y else x (* Function: standard euclidean division, the rest is always positive *) val div: a:int -> b:pos -> Tot (c:int{(a < 0 ==> c < 0) /\ (a >= 0 ==> c >= 0)}) let div a b = if a < 0 then begin slash_decr_axiom (-a) b; if a % b = 0 then - (-a / b) else - (-a / b) - 1 end else a / b (* Function: equivalent of the '/' operator in C, hence the rest can be negative *) val div_non_eucl: a:int -> b:pos -> Tot (q:int{ ( a >= 0 ==> q = a / b ) /\ ( a < 0 ==> q = -((-a)/b) ) }) let div_non_eucl a b = if a < 0 then 0 - ((0 - a) / b) else a / b (* The equivalent of the << C operator *) val shift_left: v:int -> i:nat -> Tot (res:int{res = v * (pow2 i)}) let shift_left v i = v * (pow2 i) (* asr OCaml operator *) val arithmetic_shift_right: v:int -> i:nat -> Tot (res:int{ res = div v (pow2 i) }) let arithmetic_shift_right v i = div v (pow2 i) (* Case of C cast functions ? *) (* Implemented by "mod" in OCaml *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Math.Lib.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
v: Prims.int -> p: Prims.pos -> res: Prims.int{res = v - FStar.Math.Lib.div_non_eucl v p * p}
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.pos", "Prims.op_GreaterThanOrEqual", "Prims.op_Modulus", "Prims.bool", "Prims.op_Subtraction", "Prims.b2t", "Prims.op_Equality", "FStar.Mul.op_Star", "FStar.Math.Lib.div_non_eucl" ]
[]
false
false
false
false
false
let signed_modulo v p =
if v >= 0 then v % p else 0 - ((0 - v) % p)
false
FStar.Math.Lib.fst
FStar.Math.Lib.div_non_eucl_decr_lemma
val div_non_eucl_decr_lemma: a:int -> b:pos -> Lemma (abs (div_non_eucl a b) <= abs a)
val div_non_eucl_decr_lemma: a:int -> b:pos -> Lemma (abs (div_non_eucl a b) <= abs a)
let div_non_eucl_decr_lemma a b = slash_decr_axiom (abs a) b
{ "file_name": "ulib/FStar.Math.Lib.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 140, "start_col": 0, "start_line": 139 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Math.Lib open FStar.Mul (* Definition of the division operator *) val lemma_div_def: a:nat -> b:pos -> Lemma (a = b * (a/b) + a % b) let lemma_div_def a b = () private let mul_lemma (a:nat) (b:nat) (c:nat) : Lemma (requires (a <= b)) (ensures (c * a <= c * b)) = () private let mul_lemma' (a:nat) (b:nat) (c:pos) : Lemma (requires (c * a <= c * b)) (ensures (a <= b)) = () private let mul_div_lemma (a:nat) (b:pos) : Lemma (b * (a / b) <= a) = () val slash_decr_axiom: a:nat -> b:pos -> Lemma (a / b <= a) let slash_decr_axiom a b = mul_lemma 1 b a; mul_div_lemma a b; mul_lemma' (a / b) a b private let lemma_mul_minus_distr_l (a:int) (b:int) (c:int) : Lemma (a * (b - c) = a * b - a * c) = () (* Axiom: definition of the "b divides c" relation *) #reset-options "--z3rlimit 30" val slash_star_axiom: a:nat -> b:pos -> c:nat -> Lemma (requires (a * b = c)) (ensures (a = c / b)) let slash_star_axiom a b c = lemma_div_def c b; lemma_mul_minus_distr_l b a (c/b) #reset-options val log_2: x:pos -> Tot nat let rec log_2 x = if x >= 2 then 1 + log_2 (x / 2) else 0 (* Function: power of x *) val powx : x:int -> n:nat -> Tot int let rec powx x n = match n with | 0 -> 1 | n -> x * powx x (n - 1) (* Function: absolute value *) val abs: x:int -> Tot (y:int{ (x >= 0 ==> y = x) /\ (x < 0 ==> y = -x) }) let abs x = if x >= 0 then x else -x (* Function: maximum value *) val max: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = x) /\ (x < y ==> z = y) }) let max x y = if x >= y then x else y (* Function: minimum value *) val min: x:int -> y:int -> Tot (z:int{ (x >= y ==> z = y) /\ (x < y ==> z = x) }) let min x y = if x >= y then y else x (* Function: standard euclidean division, the rest is always positive *) val div: a:int -> b:pos -> Tot (c:int{(a < 0 ==> c < 0) /\ (a >= 0 ==> c >= 0)}) let div a b = if a < 0 then begin slash_decr_axiom (-a) b; if a % b = 0 then - (-a / b) else - (-a / b) - 1 end else a / b (* Function: equivalent of the '/' operator in C, hence the rest can be negative *) val div_non_eucl: a:int -> b:pos -> Tot (q:int{ ( a >= 0 ==> q = a / b ) /\ ( a < 0 ==> q = -((-a)/b) ) }) let div_non_eucl a b = if a < 0 then 0 - ((0 - a) / b) else a / b (* The equivalent of the << C operator *) val shift_left: v:int -> i:nat -> Tot (res:int{res = v * (pow2 i)}) let shift_left v i = v * (pow2 i) (* asr OCaml operator *) val arithmetic_shift_right: v:int -> i:nat -> Tot (res:int{ res = div v (pow2 i) }) let arithmetic_shift_right v i = div v (pow2 i) (* Case of C cast functions ? *) (* Implemented by "mod" in OCaml *) val signed_modulo: v:int -> p:pos -> Tot (res:int{ res = v - ((div_non_eucl v p) * p) }) let signed_modulo v p = if v >= 0 then v % p else 0 - ( (0-v) % p) val op_Plus_Percent : a:int -> p:pos -> Tot (res:int{ (a >= 0 ==> res = a % p) /\ (a < 0 ==> res = -((-a) % p)) }) let op_Plus_Percent a p = signed_modulo a p (** Useful lemmas for future proofs **) (* Lemmas of x^n *) val powx_lemma1: a:int -> Lemma (powx a 1 = a) let powx_lemma1 a = () val powx_lemma2: x:int -> n:nat -> m:nat -> Lemma (powx x n * powx x m = powx x (n + m)) let rec powx_lemma2 x n m = let ass (x y z : int) : Lemma ((x*y)*z == x*(y*z)) = () in match n with | 0 -> () | _ -> powx_lemma2 x (n-1) m; ass x (powx x (n-1)) (powx x m) (* Lemma: absolute value of product is the product of the absolute values *) val abs_mul_lemma: a:int -> b:int -> Lemma (abs (a * b) = abs a * abs b) let abs_mul_lemma a b = () (* Lemma: absolute value of a signed_module b is bounded by b *) val signed_modulo_property: v:int -> p:pos -> Lemma (abs (signed_modulo v p ) < p) let signed_modulo_property v p = () (* Lemma: non-Euclidean division has a smaller output compared to its input *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Math.Lib.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Prims.int -> b: Prims.pos -> FStar.Pervasives.Lemma (ensures FStar.Math.Lib.abs (FStar.Math.Lib.div_non_eucl a b) <= FStar.Math.Lib.abs a)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Prims.pos", "FStar.Math.Lib.slash_decr_axiom", "FStar.Math.Lib.abs", "Prims.unit" ]
[]
true
false
true
false
false
let div_non_eucl_decr_lemma a b =
slash_decr_axiom (abs a) b
false
FStar.Math.Lib.fst
FStar.Math.Lib.slash_star_axiom
val slash_star_axiom: a:nat -> b:pos -> c:nat -> Lemma (requires (a * b = c)) (ensures (a = c / b))
val slash_star_axiom: a:nat -> b:pos -> c:nat -> Lemma (requires (a * b = c)) (ensures (a = c / b))
let slash_star_axiom a b c = lemma_div_def c b; lemma_mul_minus_distr_l b a (c/b)
{ "file_name": "ulib/FStar.Math.Lib.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 50, "start_col": 0, "start_line": 48 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Math.Lib open FStar.Mul (* Definition of the division operator *) val lemma_div_def: a:nat -> b:pos -> Lemma (a = b * (a/b) + a % b) let lemma_div_def a b = () private let mul_lemma (a:nat) (b:nat) (c:nat) : Lemma (requires (a <= b)) (ensures (c * a <= c * b)) = () private let mul_lemma' (a:nat) (b:nat) (c:pos) : Lemma (requires (c * a <= c * b)) (ensures (a <= b)) = () private let mul_div_lemma (a:nat) (b:pos) : Lemma (b * (a / b) <= a) = () val slash_decr_axiom: a:nat -> b:pos -> Lemma (a / b <= a) let slash_decr_axiom a b = mul_lemma 1 b a; mul_div_lemma a b; mul_lemma' (a / b) a b private let lemma_mul_minus_distr_l (a:int) (b:int) (c:int) : Lemma (a * (b - c) = a * b - a * c) = () (* Axiom: definition of the "b divides c" relation *) #reset-options "--z3rlimit 30" val slash_star_axiom: a:nat -> b:pos -> c:nat -> Lemma (requires (a * b = c))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Math.Lib.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Prims.nat -> b: Prims.pos -> c: Prims.nat -> FStar.Pervasives.Lemma (requires a * b = c) (ensures a = c / b)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "Prims.pos", "FStar.Math.Lib.lemma_mul_minus_distr_l", "Prims.op_Division", "Prims.unit", "FStar.Math.Lib.lemma_div_def" ]
[]
true
false
true
false
false
let slash_star_axiom a b c =
lemma_div_def c b; lemma_mul_minus_distr_l b a (c / b)
false
Vale.Math.Poly2.Galois.fsti
Vale.Math.Poly2.Galois.min
val min : x: Prims.int -> y: Prims.int -> z: Prims.int{(x >= y ==> z = y) /\ (x < y ==> z = x)}
let min = FStar.Math.Lib.min
{ "file_name": "vale/code/lib/math/Vale.Math.Poly2.Galois.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 21, "start_col": 7, "start_line": 21 }
module Vale.Math.Poly2.Galois open FStar.Mul module I = Lib.IntTypes module G = Spec.GaloisField module P = Vale.Math.Poly2_s open Vale.Math.Poly2_s open Vale.Math.Poly2 open FStar.Seq (* Connect Spec.GaloisField to Vale.Math.Poly2* *) val to_poly (#f:G.field) (e:G.felem f) : poly val to_felem (f:G.field) (p:poly) : G.felem f let irred_poly (f:G.field) : poly = let G.GF t irred = f in monomial (I.bits t) +. to_poly #f irred
{ "checked_file": "/", "dependencies": [ "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lib.fst.checked" ], "interface_file": false, "source_file": "Vale.Math.Poly2.Galois.fsti" }
[ { "abbrev": true, "full_module": "Vale.Math.Poly2.Galois.IntTypes", "short_module": "GI" }, { "abbrev": true, "full_module": "Vale.Math.Poly2.Defs_s", "short_module": "D" }, { "abbrev": true, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": "PL" }, { "abbrev": true, "full_module": "FStar.UInt", "short_module": "U" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": true, "full_module": "Vale.Math.Poly2_s", "short_module": "P" }, { "abbrev": true, "full_module": "Spec.GaloisField", "short_module": "G" }, { "abbrev": true, "full_module": "Lib.IntTypes", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
x: Prims.int -> y: Prims.int -> z: Prims.int{(x >= y ==> z = y) /\ (x < y ==> z = x)}
Prims.Tot
[ "total" ]
[]
[ "FStar.Math.Lib.min" ]
[]
false
false
false
false
false
let min =
FStar.Math.Lib.min
false
Vale.Math.Poly2.Galois.fsti
Vale.Math.Poly2.Galois.max
val max : x: Prims.int -> y: Prims.int -> z: Prims.int{(x >= y ==> z = x) /\ (x < y ==> z = y)}
let max = FStar.Math.Lib.max
{ "file_name": "vale/code/lib/math/Vale.Math.Poly2.Galois.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 22, "start_col": 7, "start_line": 22 }
module Vale.Math.Poly2.Galois open FStar.Mul module I = Lib.IntTypes module G = Spec.GaloisField module P = Vale.Math.Poly2_s open Vale.Math.Poly2_s open Vale.Math.Poly2 open FStar.Seq (* Connect Spec.GaloisField to Vale.Math.Poly2* *) val to_poly (#f:G.field) (e:G.felem f) : poly val to_felem (f:G.field) (p:poly) : G.felem f let irred_poly (f:G.field) : poly = let G.GF t irred = f in monomial (I.bits t) +. to_poly #f irred
{ "checked_file": "/", "dependencies": [ "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lib.fst.checked" ], "interface_file": false, "source_file": "Vale.Math.Poly2.Galois.fsti" }
[ { "abbrev": true, "full_module": "Vale.Math.Poly2.Galois.IntTypes", "short_module": "GI" }, { "abbrev": true, "full_module": "Vale.Math.Poly2.Defs_s", "short_module": "D" }, { "abbrev": true, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": "PL" }, { "abbrev": true, "full_module": "FStar.UInt", "short_module": "U" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": true, "full_module": "Vale.Math.Poly2_s", "short_module": "P" }, { "abbrev": true, "full_module": "Spec.GaloisField", "short_module": "G" }, { "abbrev": true, "full_module": "Lib.IntTypes", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
x: Prims.int -> y: Prims.int -> z: Prims.int{(x >= y ==> z = x) /\ (x < y ==> z = y)}
Prims.Tot
[ "total" ]
[]
[ "FStar.Math.Lib.max" ]
[]
false
false
false
false
false
let max =
FStar.Math.Lib.max
false
Hacl.Impl.Blake2.Generic.fst
Hacl.Impl.Blake2.Generic.blake2_update_last
val blake2_update_last: #al:Spec.alg -> #ms:m_spec -> blake2_update_block: blake2_update_block_st al ms -> blake2_update_last_st al ms
val blake2_update_last: #al:Spec.alg -> #ms:m_spec -> blake2_update_block: blake2_update_block_st al ms -> blake2_update_last_st al ms
let blake2_update_last #al #ms blake2_update_block #len wv hash prev rem d = let h0 = ST.get () in [@inline_let] let spec _ h1 = state_v h1 hash == Spec.blake2_update_last al (v prev) (v rem) h0.[|d|] (state_v h0 hash) in salloc1 h0 (size_block al) (u8 0) (Ghost.hide (loc hash |+| loc wv)) spec (fun last_block -> let last = sub d (len -! rem) rem in let h1 = ST.get() in update_sub last_block 0ul rem last; let h2 = ST.get() in as_seq_gsub h1 d (len -! rem) rem; assert (as_seq h1 last == Seq.sub (as_seq h1 d) (v len - v rem) (v rem)); assert (as_seq h1 last == Seq.slice (as_seq h0 d) (v len - v rem) (v len)); assert (as_seq h2 last_block == Spec.get_last_padded_block al (as_seq h0 d) (v rem)); let totlen = prev +. (size_to_limb al len) in blake2_update_block wv hash true totlen last_block; let h3 = ST.get() in assert (v totlen == v prev + v len); assert (state_v h3 hash == Spec.blake2_update_block al true (v totlen) (as_seq h2 last_block) (state_v h0 hash)))
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Generic.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 117, "end_line": 542, "start_col": 0, "start_line": 524 }
module Hacl.Impl.Blake2.Generic open FStar.Mul open FStar.HyperStack open FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.LoopCombinators module ST = FStar.HyperStack.ST module Seq = Lib.Sequence module Loops = Lib.LoopCombinators module Spec = Spec.Blake2 open Hacl.Impl.Blake2.Constants open Hacl.Impl.Blake2.Core #set-options "--z3rlimit 50 --max_ifuel 0 --max_fuel 0" noextract let is_valid_blake2_config (a : Spec.alg) (m : m_spec) = match a, m with | Spec.Blake2S, M32 | Spec.Blake2S, M128 | Spec.Blake2B, M32 | Spec.Blake2B, M256 -> true | _ -> false inline_for_extraction noextract let valid_m_spec (a : Spec.alg) = m:m_spec{is_valid_blake2_config a m} /// Accessors for constants inline_for_extraction noextract val get_iv: a:Spec.alg -> s: size_t{size_v s < 8} -> Stack (word_t a) (requires (fun h -> True)) (ensures (fun h0 z h1 -> h0 == h1 /\ v z == v (Seq.index (Spec.ivTable a) (v s)))) let get_iv a s = recall_contents #(Spec.pub_word_t Spec.Blake2S) #8ul ivTable_S (Spec.ivTable Spec.Blake2S); recall_contents #(Spec.pub_word_t Spec.Blake2B) #8ul ivTable_B (Spec.ivTable Spec.Blake2B); [@inline_let] let ivTable: (x:glbuffer (Spec.pub_word_t a) 8ul{witnessed x (Spec.ivTable a) /\ recallable x}) = match a with | Spec.Blake2S -> ivTable_S | Spec.Blake2B -> ivTable_B in let r = index ivTable s in secret #(Spec.wt a) r inline_for_extraction noextract val get_sigma: s: size_t{v s < 160} -> Stack Spec.sigma_elt_t (requires (fun h -> True)) (ensures (fun h0 z h1 -> h0 == h1 /\ z == Lib.Sequence.(Spec.sigmaTable.[v s]))) let get_sigma s = recall_contents sigmaTable Spec.sigmaTable; index sigmaTable s inline_for_extraction noextract val get_sigma_sub: start: size_t -> i: size_t{v i < 16 /\ v start + v i < 160} -> Stack Spec.sigma_elt_t (requires (fun h -> True)) (ensures (fun h0 z h1 -> h0 == h1 /\ v z == v (Seq.index Spec.sigmaTable (v start + v i)))) let get_sigma_sub start i = get_sigma (start +. i) inline_for_extraction noextract let rounds_t (a:Spec.alg): size_t = size (Spec.rounds a) inline_for_extraction noextract val size_to_word: al:Spec.alg -> s:size_t -> u:word_t al{u == Spec.nat_to_word al (v s)} let size_to_word al s = match al with | Spec.Blake2S -> size_to_uint32 s | Spec.Blake2B -> size_to_uint64 s inline_for_extraction noextract val size_to_limb: al:Spec.alg -> s:size_t -> u:Spec.limb_t al{u == Spec.nat_to_limb al (v s)} let size_to_limb al s = match al with | Spec.Blake2S -> size_to_uint64 s | Spec.Blake2B -> to_u128 (size_to_uint64 s) /// Constants /// Define algorithm functions inline_for_extraction noextract val g1: #al:Spec.alg -> #m:m_spec -> wv:state_p al m -> a:index_t -> b:index_t -> r:rotval (Spec.wt al) -> Stack unit (requires (fun h -> live h wv /\ a <> b)) (ensures (fun h0 _ h1 -> modifies (loc wv) h0 h1 /\ (state_v h1 wv) == Spec.g1 al (state_v h0 wv) (v a) (v b) r)) let g1 #al #m wv a b r = let h0 = ST.get() in let wv_a = rowi wv a in let wv_b = rowi wv b in xor_row wv_a wv_b; ror_row wv_a r; let h2 = ST.get() in Lib.Sequence.eq_intro (state_v h2 wv) (Spec.g1 al (state_v h0 wv) (v a) (v b) r) #push-options "--z3rlimit 100 --max_fuel 1 --max_ifuel 1" inline_for_extraction noextract val g2: #al:Spec.alg -> #m:m_spec -> wv:state_p al m -> a:index_t -> b:index_t -> x:row_p al m -> Stack unit (requires (fun h -> live h wv /\ live h x /\ disjoint wv x /\ a <> b)) (ensures (fun h0 _ h1 -> modifies (loc wv) h0 h1 /\ state_v h1 wv == Spec.g2 al (state_v h0 wv) (v a) (v b) (row_v h0 x))) let g2 #al #m wv a b x = let h0 = ST.get() in let wv_a = rowi wv a in let wv_b = rowi wv b in add_row wv_a wv_b; add_row wv_a x; let h1 = ST.get() in Lib.Sequence.eq_intro (state_v h1 wv) (Spec.g2 al (state_v h0 wv) (v a) (v b) (row_v h0 x)) #push-options "--z3rlimit 100 --max_fuel 1 --max_ifuel 1" inline_for_extraction noextract val g2z: #al:Spec.alg -> #m:m_spec -> wv:state_p al m -> a:index_t -> b:index_t -> Stack unit (requires (fun h -> live h wv /\ a <> b)) (ensures (fun h0 _ h1 -> modifies (loc wv) h0 h1 /\ state_v h1 wv == Spec.g2z al (state_v h0 wv) (v a) (v b))) let g2z #al #m wv a b = let h0 = ST.get() in let wv_a = rowi wv a in let wv_b = rowi wv b in add_row wv_a wv_b; let h1 = ST.get() in Lib.Sequence.eq_intro (state_v h1 wv) (Spec.g2z al (state_v h0 wv) (v a) (v b)) inline_for_extraction noextract val blake2_mixing : #al:Spec.alg -> #m:m_spec -> wv:state_p al m -> x:row_p al m -> y:row_p al m -> Stack unit (requires (fun h -> live h wv /\ live h x /\ live h y /\ disjoint wv x /\ disjoint wv y)) (ensures (fun h0 _ h1 -> modifies (loc wv) h0 h1 /\ state_v h1 wv == Spec.blake2_mixing al (state_v h0 wv) (row_v h0 x) (row_v h0 y))) let blake2_mixing #al #m wv x y = let h0 = ST.get() in push_frame (); let a = 0ul in let b = 1ul in let c = 2ul in let d = 3ul in [@inline_let] let r0 = normalize_term (Lib.Sequence.index (Spec.rTable al) 0) in normalize_term_spec (Lib.Sequence.index (Spec.rTable al) 0); [@inline_let] let r1 = normalize_term (Lib.Sequence.index (Spec.rTable al) 1) in normalize_term_spec (Lib.Sequence.index (Spec.rTable al) 1); [@inline_let] let r2 = normalize_term (Lib.Sequence.index (Spec.rTable al) 2) in normalize_term_spec (Lib.Sequence.index (Spec.rTable al) 2); [@inline_let] let r3 = normalize_term (Lib.Sequence.index (Spec.rTable al) 3) in normalize_term_spec (Lib.Sequence.index (Spec.rTable al) 3); let h1 = ST.get() in g2 wv a b x; g1 wv d a r0; g2z wv c d; g1 wv b c r1; g2 wv a b y; g1 wv d a r2; g2z wv c d; g1 wv b c r3; let h2 = ST.get() in pop_frame (); let h3 = ST.get() in assert(modifies (loc wv) h0 h3); Lib.Sequence.eq_intro (state_v h2 wv) (Spec.blake2_mixing al (state_v h1 wv) (row_v h1 x) (row_v h1 y)) #pop-options inline_for_extraction noextract val diag: #a:Spec.alg -> #m:m_spec -> wv:state_p a m -> Stack unit (requires (fun h -> live h wv)) (ensures (fun h0 _ h1 -> modifies (loc wv) h0 h1 /\ state_v h1 wv == Spec.diag (state_v h0 wv))) let diag #a #m wv = let r1 = rowi wv 1ul in let r2 = rowi wv 2ul in let r3 = rowi wv 3ul in let h0 = ST.get() in permr_row r1 1ul; permr_row r2 2ul; permr_row r3 3ul inline_for_extraction noextract val undiag: #a:Spec.alg -> #m:m_spec -> wv:state_p a m -> Stack unit (requires (fun h -> live h wv)) (ensures (fun h0 _ h1 -> modifies (loc wv) h0 h1 /\ state_v h1 wv == Spec.undiag (state_v h0 wv))) let undiag #a #m wv = let r1 = rowi wv 1ul in let r2 = rowi wv 2ul in let r3 = rowi wv 3ul in let h0 = ST.get() in permr_row r1 3ul; permr_row r2 2ul; permr_row r3 1ul inline_for_extraction noextract val gather_state: #a:Spec.alg -> #ms:m_spec -> st:state_p a ms -> m:block_w a -> start:size_t{v start <= 144} -> Stack unit (requires (fun h -> live h st /\ live h m /\ disjoint st m)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ state_v h1 st == Spec.gather_state a (as_seq h0 m) (v start))) inline_for_extraction noextract let get_sigma' (start: size_t { v start <= 144 }) (i: size_t { normalize (i <=. 15ul) }): Stack Spec.sigma_elt_t (requires (fun h -> True)) (ensures (fun h0 z h1 -> h0 == h1 /\ z == Lib.Sequence.(Spec.sigmaTable.[v start + v i]))) = get_sigma (start +! i) #push-options "--z3rlimit 500" let gather_state #a #ms st m start = let h0 = ST.get() in let r0 = rowi st 0ul in let r1 = rowi st 1ul in let r2 = rowi st 2ul in let r3 = rowi st 3ul in let s0 = get_sigma' start 0ul in let s1 = get_sigma' start 1ul in let s2 = get_sigma' start 2ul in let s3 = get_sigma' start 3ul in let s4 = get_sigma' start 4ul in let s5 = get_sigma' start 5ul in let s6 = get_sigma' start 6ul in let s7 = get_sigma' start 7ul in let s8 = get_sigma' start 8ul in let s9 = get_sigma' start 9ul in let s10 = get_sigma' start 10ul in let s11 = get_sigma' start 11ul in let s12 = get_sigma' start 12ul in let s13 = get_sigma' start 13ul in let s14 = get_sigma' start 14ul in let s15 = get_sigma' start 15ul in let h1 = ST.get() in gather_row r0 m s0 s2 s4 s6; let h2 = ST.get() in gather_row r1 m s1 s3 s5 s7; let h3 = ST.get() in gather_row r2 m s8 s10 s12 s14; let h4 = ST.get() in gather_row r3 m s9 s11 s13 s15; let h5 = ST.get() in assert(modifies (loc st) h0 h5); Lib.Sequence.eq_intro (state_v h5 st) (Spec.gather_state a (as_seq h0 m) (v start)) inline_for_extraction noextract val blake2_round : #al:Spec.alg -> #ms:m_spec -> wv:state_p al ms -> m:block_w al -> i:size_t -> Stack unit (requires (fun h -> live h wv /\ live h m /\ disjoint wv m)) (ensures (fun h0 _ h1 -> modifies (loc wv) h0 h1 /\ state_v h1 wv == Spec.blake2_round al (as_seq h0 m) (v i) (state_v h0 wv))) let blake2_round #al #ms wv m i = push_frame(); let start_idx = (i %. size 10) *. size 16 in assert (v start_idx == (v i % 10) * 16); assert (v start_idx <= 144); let m_st = alloc_state al ms in gather_state m_st m start_idx; let x = rowi m_st 0ul in let y = rowi m_st 1ul in let z = rowi m_st 2ul in let w = rowi m_st 3ul in let h1 = ST.get() in assert (disjoint wv m_st); assert (disjoint m_st wv); assert (disjoint x wv); assert (disjoint wv x); assert (disjoint y wv); assert (disjoint wv y); assert (disjoint z wv); assert (disjoint wv z); assert (disjoint w wv); assert (disjoint wv w); blake2_mixing wv x y; diag wv; blake2_mixing wv z w; undiag wv; pop_frame () inline_for_extraction noextract val blake2_compress0: #al:Spec.alg -> m_s: block_p al -> m_w: block_w al -> Stack unit (requires (fun h -> live h m_s /\ live h m_w /\ disjoint m_s m_w)) (ensures (fun h0 _ h1 -> modifies (loc m_w) h0 h1 /\ as_seq h1 m_w == Spec.blake2_compress0 al (as_seq h0 m_s))) let blake2_compress0 #al m_s m_w = uints_from_bytes_le m_w m_s inline_for_extraction noextract val blake2_compress1: #al:Spec.alg -> #m:m_spec -> wv: state_p al m -> s_iv: state_p al m -> offset: Spec.limb_t al -> flag: bool -> Stack unit (requires (fun h -> live h wv /\ live h s_iv /\ disjoint wv s_iv)) (ensures (fun h0 _ h1 -> modifies (loc wv) h0 h1 /\ state_v h1 wv == Spec.blake2_compress1 al (state_v h0 s_iv) offset flag)) let blake2_compress1 #al #m wv s_iv offset flag = let h0 = ST.get() in push_frame(); let mask = alloc_row al m in [@inline_let] let wv_12 = Spec.limb_to_word al offset in [@inline_let] let wv_13 = Spec.limb_to_word al (offset >>. (size (bits (Spec.wt al)))) in // SH: TODO: for some reason, ``ones`` below doesn't get inlined by KaRaMeL, // causing an extraction problem. The 3 lines below are a hack to fix // extraction for the time being: // [> let wv_14 = if flag then (ones (Spec.wt al) SEC) else (Spec.zero al) in // After investigation, it is because ones is [@(strict_on_arguments [0])], // and so isn't unfolded if its first argument is not normalized to a constant. // However, the first argument should always be normalized (I checked the // output generated by KaRaMeL and the definitions). (**) normalize_term_spec (Spec.wt al); [@inline_let] let wt_al = normalize_term (Spec.wt al) in let wv_14 = if flag then ones wt_al SEC else (Spec.zero al) in // end of the TODO let wv_15 = Spec.zero al in create_row mask wv_12 wv_13 wv_14 wv_15; copy_state wv s_iv; let wv3 = rowi wv 3ul in xor_row wv3 mask; pop_frame(); let h1 = ST.get() in assert(modifies (loc wv) h0 h1); Lib.Sequence.eq_intro (state_v h1 wv) (Spec.blake2_compress1 al (state_v h0 s_iv) offset flag) inline_for_extraction noextract val blake2_compress2 : #al:Spec.alg -> #ms:m_spec -> wv: state_p al ms -> m: block_w al -> Stack unit (requires (fun h -> live h wv /\ live h m /\ disjoint wv m)) (ensures (fun h0 _ h1 -> modifies1 wv h0 h1 /\ state_v h1 wv == Spec.blake2_compress2 al (state_v h0 wv) (as_seq h0 m))) #push-options "--z3rlimit 400" let blake2_compress2 #al #ms wv m = let h0 = ST.get () in [@inline_let] let a_spec = Spec.state al in [@inline_let] let refl h = state_v h wv in [@inline_let] let footprint = Ghost.hide(loc wv) in [@inline_let] let spec h = Spec.blake2_round al h.[|m|] in loop_refl h0 (rounds_t al) a_spec refl footprint spec (fun i -> Loops.unfold_repeati (Spec.rounds al) (spec h0) (state_v h0 wv) (v i); blake2_round wv m i) #pop-options inline_for_extraction noextract val blake2_compress3 : #al:Spec.alg -> #ms:m_spec -> s_iv:state_p al ms -> wv:state_p al ms -> Stack unit (requires (fun h -> live h s_iv /\ live h wv /\ disjoint s_iv wv)) (ensures (fun h0 _ h1 -> modifies (loc s_iv) h0 h1 /\ state_v h1 s_iv == Spec.blake2_compress3 al (state_v h0 wv) (state_v h0 s_iv))) let blake2_compress3 #al #ms s_iv wv = let h0 = ST.get() in let s0 = rowi s_iv 0ul in let s1 = rowi s_iv 1ul in let r0 = rowi wv 0ul in let r1 = rowi wv 1ul in let r2 = rowi wv 2ul in let r3 = rowi wv 3ul in assert (disjoint s0 wv); assert (disjoint wv s0); assert (disjoint s1 wv); assert (disjoint wv s1); assert (disjoint r0 s0); assert (disjoint r2 s0); assert (disjoint r1 s1); assert (disjoint r3 s1); xor_row s0 r0; let h1 = ST.get() in xor_row s0 r2; let h2 = ST.get() in xor_row s1 r1; let h3 = ST.get() in xor_row s1 r3; let h4 = ST.get() in assert (modifies (loc s_iv) h0 h4); let open Lib.Sequence in assert (row_v h0 r0 == (state_v h0 wv).[0]); assert (row_v h1 r2 == (state_v h0 wv).[2]); assert (row_v h4 s0 == Spec.(((state_v h0 s_iv).[0] ^| (state_v h0 wv).[0]) ^| (state_v h0 wv).[2])); assert (row_v h4 s1 == Spec.(((state_v h0 s_iv).[1] ^| (state_v h0 wv).[1]) ^| (state_v h0 wv).[3])); eq_intro (state_v h2 s_iv) ((state_v h0 s_iv).[0] <- row_v h4 s0); eq_intro (state_v h4 s_iv) ((state_v h2 s_iv).[1] <- row_v h4 s1); eq_intro (state_v h4 s_iv) (Spec.blake2_compress3 al (state_v h0 wv) (state_v h0 s_iv)) inline_for_extraction noextract let compress_t (al:Spec.alg) (ms:m_spec) = wv:state_p al ms -> s: state_p al ms -> m: block_p al -> offset: Spec.limb_t al -> flag: bool -> Stack unit (requires (fun h -> live h wv /\ live h s /\ live h m /\ disjoint s m /\ disjoint wv s /\ disjoint wv m)) (ensures (fun h0 _ h1 -> modifies (loc s |+| loc wv) h0 h1 /\ state_v h1 s == Spec.blake2_compress al (state_v h0 s) h0.[|m|] offset flag)) inline_for_extraction noextract val blake2_compress: #al:Spec.alg -> #ms:m_spec -> compress_t al ms let blake2_compress #al #ms wv s m offset flag = push_frame(); let m_w = create 16ul (Spec.zero al) in blake2_compress0 #al m m_w; blake2_compress1 wv s offset flag; blake2_compress2 wv m_w; blake2_compress3 s wv; pop_frame() inline_for_extraction noextract let blake2_update_block_st (al:Spec.alg) (ms:m_spec) = wv:state_p al ms -> hash: state_p al ms -> flag: bool -> totlen: Spec.limb_t al{v totlen <= Spec.max_limb al} -> d: block_p al -> Stack unit (requires (fun h -> live h wv /\ live h hash /\ live h d /\ disjoint hash d /\ disjoint wv hash /\ disjoint wv d)) (ensures (fun h0 _ h1 -> modifies (loc hash |+| loc wv) h0 h1 /\ state_v h1 hash == Spec.blake2_update_block al flag (v totlen) h0.[|d|] (state_v h0 hash))) inline_for_extraction noextract val blake2_update_block: #al:Spec.alg -> #ms:m_spec -> blake2_update_block_st al ms let blake2_update_block #al #ms wv hash flag totlen d = blake2_compress wv hash d totlen flag inline_for_extraction noextract let blake2_update1_st (al:Spec.alg) (ms:m_spec) = #len:size_t -> wv: state_p al ms -> hash: state_p al ms -> prev: Spec.limb_t al{v prev + v len <= Spec.max_limb al} -> d: lbuffer uint8 len -> i: size_t{v i < length d / Spec.size_block al} -> Stack unit (requires (fun h -> live h wv /\ live h hash /\ live h d /\ disjoint hash d /\ disjoint wv hash /\ disjoint wv d)) (ensures (fun h0 _ h1 -> modifies (loc hash |+| loc wv) h0 h1 /\ state_v h1 hash == Spec.blake2_update1 al (v prev) h0.[|d|] (v i) (state_v h0 hash))) inline_for_extraction noextract val blake2_update1: #al:Spec.alg -> #ms:m_spec -> blake2_update_block: blake2_update_block_st al ms -> blake2_update1_st al ms let blake2_update1 #al #ms blake2_update_block #len wv hash prev d i = let totlen = prev +. size_to_limb al ((i+!1ul) *! size_block al) in assert (v totlen == v prev + (v i + 1) * Spec.size_block al); let b = sub d (i *. size_block al) (size_block al) in let h = ST.get() in assert (as_seq h b == Spec.get_blocki al (as_seq h d) (v i)); blake2_update_block wv hash false totlen b inline_for_extraction noextract let blake2_update_last_st (al:Spec.alg) (ms:m_spec) = #len:size_t -> wv: state_p al ms -> hash: state_p al ms -> prev: Spec.limb_t al{v prev + v len <= Spec.max_limb al} -> rem: size_t {v rem <= v len /\ v rem <= Spec.size_block al} -> d: lbuffer uint8 len -> Stack unit (requires (fun h -> live h wv /\ live h hash /\ live h d /\ disjoint hash d /\ disjoint wv hash /\ disjoint wv d)) (ensures (fun h0 _ h1 -> modifies (loc hash |+| loc wv) h0 h1 /\ state_v h1 hash == Spec.blake2_update_last al (v prev) (v rem) h0.[|d|] (state_v h0 hash))) inline_for_extraction noextract val blake2_update_last: #al:Spec.alg -> #ms:m_spec -> blake2_update_block: blake2_update_block_st al ms -> blake2_update_last_st al ms
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "Hacl.Impl.Blake2.Constants.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Generic.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.Blake2.Core", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Blake2.Constants", "short_module": null }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Blake2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Blake2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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": 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": false, "smtencoding_l_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": 500, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
blake2_update_block: Hacl.Impl.Blake2.Generic.blake2_update_block_st al ms -> Hacl.Impl.Blake2.Generic.blake2_update_last_st al ms
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "Hacl.Impl.Blake2.Core.m_spec", "Hacl.Impl.Blake2.Generic.blake2_update_block_st", "Lib.IntTypes.size_t", "Hacl.Impl.Blake2.Core.state_p", "Spec.Blake2.Definitions.limb_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.v", "Spec.Blake2.Definitions.limb_inttype", "Lib.IntTypes.SEC", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Spec.Blake2.Definitions.max_limb", "Prims.l_and", "Spec.Blake2.Definitions.size_block", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Lib.Buffer.salloc1", "Prims.unit", "Hacl.Impl.Blake2.Core.size_block", "Lib.IntTypes.u8", "FStar.Ghost.hide", "LowStar.Monotonic.Buffer.loc", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.Buffer.loc", "Lib.Buffer.MUT", "Hacl.Impl.Blake2.Core.element_t", "Prims._assert", "Prims.eq2", "Spec.Blake2.Definitions.state", "Hacl.Impl.Blake2.Core.state_v", "Spec.Blake2.blake2_update_block", "Lib.Buffer.as_seq", "Prims.int", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.IntTypes.int_t", "Spec.Blake2.Definitions.wt", "Lib.IntTypes.U64", "Lib.IntTypes.U128", "Lib.IntTypes.op_Plus_Dot", "Hacl.Impl.Blake2.Generic.size_to_limb", "Lib.Sequence.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Spec.Blake2.get_last_padded_block", "Prims.op_Subtraction", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.slice", "Prims.l_Forall", "Prims.op_LessThan", "FStar.Seq.Base.index", "Lib.Sequence.index", "Lib.Sequence.slice", "Lib.Sequence.lseq", "Lib.Sequence.sub", "Lib.Buffer.as_seq_gsub", "Lib.IntTypes.op_Subtraction_Bang", "Lib.Buffer.update_sub", "FStar.UInt32.__uint_to_t", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.U8", "Lib.Buffer.sub", "Prims.logical", "Spec.Blake2.blake2_update_last", "Lib.Buffer.op_Brack_Lens_Access" ]
[]
false
false
false
false
false
let blake2_update_last #al #ms blake2_update_block #len wv hash prev rem d =
let h0 = ST.get () in [@@ inline_let ]let spec _ h1 = state_v h1 hash == Spec.blake2_update_last al (v prev) (v rem) h0.[| d |] (state_v h0 hash) in salloc1 h0 (size_block al) (u8 0) (Ghost.hide (loc hash |+| loc wv)) spec (fun last_block -> let last = sub d (len -! rem) rem in let h1 = ST.get () in update_sub last_block 0ul rem last; let h2 = ST.get () in as_seq_gsub h1 d (len -! rem) rem; assert (as_seq h1 last == Seq.sub (as_seq h1 d) (v len - v rem) (v rem)); assert (as_seq h1 last == Seq.slice (as_seq h0 d) (v len - v rem) (v len)); assert (as_seq h2 last_block == Spec.get_last_padded_block al (as_seq h0 d) (v rem)); let totlen = prev +. (size_to_limb al len) in blake2_update_block wv hash true totlen last_block; let h3 = ST.get () in assert (v totlen == v prev + v len); assert (state_v h3 hash == Spec.blake2_update_block al true (v totlen) (as_seq h2 last_block) (state_v h0 hash)))
false
Vale.Math.Poly2.Galois.fsti
Vale.Math.Poly2.Galois.irred_poly
val irred_poly (f: G.field) : poly
val irred_poly (f: G.field) : poly
let irred_poly (f:G.field) : poly = let G.GF t irred = f in monomial (I.bits t) +. to_poly #f irred
{ "file_name": "vale/code/lib/math/Vale.Math.Poly2.Galois.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 41, "end_line": 19, "start_col": 0, "start_line": 17 }
module Vale.Math.Poly2.Galois open FStar.Mul module I = Lib.IntTypes module G = Spec.GaloisField module P = Vale.Math.Poly2_s open Vale.Math.Poly2_s open Vale.Math.Poly2 open FStar.Seq (* Connect Spec.GaloisField to Vale.Math.Poly2* *) val to_poly (#f:G.field) (e:G.felem f) : poly val to_felem (f:G.field) (p:poly) : G.felem f
{ "checked_file": "/", "dependencies": [ "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lib.fst.checked" ], "interface_file": false, "source_file": "Vale.Math.Poly2.Galois.fsti" }
[ { "abbrev": true, "full_module": "Vale.Math.Poly2.Galois.IntTypes", "short_module": "GI" }, { "abbrev": true, "full_module": "Vale.Math.Poly2.Defs_s", "short_module": "D" }, { "abbrev": true, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": "PL" }, { "abbrev": true, "full_module": "FStar.UInt", "short_module": "U" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": true, "full_module": "Vale.Math.Poly2_s", "short_module": "P" }, { "abbrev": true, "full_module": "Spec.GaloisField", "short_module": "G" }, { "abbrev": true, "full_module": "Lib.IntTypes", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: Spec.GaloisField.field -> Vale.Math.Poly2_s.poly
Prims.Tot
[ "total" ]
[]
[ "Spec.GaloisField.field", "Lib.IntTypes.inttype", "Prims.l_and", "Prims.b2t", "Lib.IntTypes.unsigned", "Prims.op_disEquality", "Lib.IntTypes.U1", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Vale.Math.Poly2.op_Plus_Dot", "Vale.Math.Poly2_s.monomial", "Lib.IntTypes.bits", "Vale.Math.Poly2.Galois.to_poly", "Vale.Math.Poly2_s.poly" ]
[]
false
false
false
true
false
let irred_poly (f: G.field) : poly =
let G.GF t irred = f in monomial (I.bits t) +. to_poly #f irred
false
Hacl.Impl.Blake2.Generic.fst
Hacl.Impl.Blake2.Generic.serialize_params_blake2b
val serialize_params_blake2b (kk: size_t{v kk <= Spec.max_key Spec.Blake2B}) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2B}) (p: blake2_params Spec.Blake2B) (b: lbuffer (word_t Spec.Blake2B) 8ul) : Stack unit (requires fun h -> live h b /\ blake2_params_inv #Spec.Blake2B h p /\ LowStar.Buffer.loc_disjoint (loc b) (blake2_params_loc p) /\ as_seq h b == Seq.create 8 (u64 0)) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Spec.serialize_blake2_params (Spec.set_key_length (Spec.set_digest_length (blake2_params_v h0 p) (v nn)) (v kk)))
val serialize_params_blake2b (kk: size_t{v kk <= Spec.max_key Spec.Blake2B}) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2B}) (p: blake2_params Spec.Blake2B) (b: lbuffer (word_t Spec.Blake2B) 8ul) : Stack unit (requires fun h -> live h b /\ blake2_params_inv #Spec.Blake2B h p /\ LowStar.Buffer.loc_disjoint (loc b) (blake2_params_loc p) /\ as_seq h b == Seq.create 8 (u64 0)) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Spec.serialize_blake2_params (Spec.set_key_length (Spec.set_digest_length (blake2_params_v h0 p) (v nn)) (v kk)))
let serialize_params_blake2b (kk:size_t{v kk <= Spec.max_key Spec.Blake2B}) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2B}) (p: blake2_params Spec.Blake2B) (b: lbuffer (word_t Spec.Blake2B) 8ul) : Stack unit (requires fun h -> live h b /\ blake2_params_inv #Spec.Blake2B h p /\ LowStar.Buffer.loc_disjoint (loc b) (blake2_params_loc p) /\ as_seq h b == Seq.create 8 (u64 0) ) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Spec.serialize_blake2_params (Spec.set_key_length (Spec.set_digest_length (blake2_params_v h0 p) (v nn)) (v kk))) = let h0 = ST.get () in [@inline_let] let kk_shift_8 = shift_left (to_u64 kk) (size 8) in [@inline_let] let fanout_shift_16 = shift_left (to_u64 p.fanout) (size 16) in [@inline_let] let depth_shift_24 = shift_left (to_u64 p.depth) (size 24) in [@inline_let] let leaf_length_shift_32 = shift_left (to_u64 p.leaf_length) (size 32) in [@inline_let] let v0 = (to_u64 nn) ^. kk_shift_8 ^. fanout_shift_16 ^. depth_shift_24 ^. leaf_length_shift_32 in [@inline_let] let xof_length_shift_32 = shift_left (to_u64 p.xof_length) (size 32) in [@inline_let] let v1 = (to_u64 p.node_offset) ^. xof_length_shift_32 in [@inline_let] let inner_length_shift_8 = shift_left (to_u64 p.inner_length) (size 8) in [@inline_let] let v2 = (to_u64 p.node_depth) ^. inner_length_shift_8 in uints_from_bytes_le (sub b 4ul 2ul) p.salt; uints_from_bytes_le (sub b 6ul 2ul) p.personal; b.(0ul) <- v0; b.(1ul) <- v1; b.(2ul) <- v2; b.(3ul) <- (u64 0); let h1 = ST.get () in let aux () : Lemma (as_seq h1 b `Seq.equal` Spec.serialize_blake2b_params (Spec.set_key_length (Spec.set_digest_length (blake2_params_v h0 p) (v nn)) (v kk))) = let open Lib.Sequence in let open Lib.ByteSequence in let s0 = (u64 (v nn)) ^. (u64 (v kk) <<. (size 8)) ^. (u64 (v p.fanout) <<. (size 16)) ^. (u64 (v p.depth) <<. (size 24)) ^. (u64 (v p.leaf_length) <<. (size 32)) in let s1 = (u64 (v p.node_offset)) ^. (u64 (v p.xof_length) <<. (size 32)) in // The serialization corresponding to s2 contains node_depth and inner_length, // followed by the 14 reserved bytes which always seem to be zeros, and can hence // be ignored when building the corresponding uint64 using xor's let s2 = (u64 (v p.node_depth)) ^. (u64 (v p.inner_length) <<. (size 8)) in // s3 corresponds to the remaining of the reserved bytes let s3 = u64 0 in let salt_u64: lseq uint64 2 = uints_from_bytes_le (as_seq h0 (get_salt p)) in let s4 = salt_u64.[0] in let s5 = salt_u64.[1] in let personal_u64: lseq uint64 2 = uints_from_bytes_le (as_seq h0 (get_personal p)) in let s6 = personal_u64.[0] in let s7 = personal_u64.[1] in [@inline_let] let l = [s0; s1; s2; s3; s4; s5; s6; s7] in assert_norm (List.Tot.length l == 8); // There seems to be something not triggering with createL, requiring the // following lemma calls, and assert_norms to relate List.index to the // actual elements assert_norm (List.Tot.index l 0 == s0); assert_norm (List.Tot.index l 1 == s1); assert_norm (List.Tot.index l 2 == s2); assert_norm (List.Tot.index l 3 == s3); assert_norm (List.Tot.index l 4 == s4); assert_norm (List.Tot.index l 5 == s5); assert_norm (List.Tot.index l 6 == s6); assert_norm (List.Tot.index l 7 == s7); of_list_index l 0; of_list_index l 1; of_list_index l 2; of_list_index l 3; of_list_index l 4; of_list_index l 5; of_list_index l 6; of_list_index l 7 in aux()
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Generic.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 9, "end_line": 760, "start_col": 0, "start_line": 667 }
module Hacl.Impl.Blake2.Generic open FStar.Mul open FStar.HyperStack open FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.LoopCombinators module ST = FStar.HyperStack.ST module Seq = Lib.Sequence module Loops = Lib.LoopCombinators module Spec = Spec.Blake2 open Hacl.Impl.Blake2.Constants open Hacl.Impl.Blake2.Core #set-options "--z3rlimit 50 --max_ifuel 0 --max_fuel 0" noextract let is_valid_blake2_config (a : Spec.alg) (m : m_spec) = match a, m with | Spec.Blake2S, M32 | Spec.Blake2S, M128 | Spec.Blake2B, M32 | Spec.Blake2B, M256 -> true | _ -> false inline_for_extraction noextract let valid_m_spec (a : Spec.alg) = m:m_spec{is_valid_blake2_config a m} /// Accessors for constants inline_for_extraction noextract val get_iv: a:Spec.alg -> s: size_t{size_v s < 8} -> Stack (word_t a) (requires (fun h -> True)) (ensures (fun h0 z h1 -> h0 == h1 /\ v z == v (Seq.index (Spec.ivTable a) (v s)))) let get_iv a s = recall_contents #(Spec.pub_word_t Spec.Blake2S) #8ul ivTable_S (Spec.ivTable Spec.Blake2S); recall_contents #(Spec.pub_word_t Spec.Blake2B) #8ul ivTable_B (Spec.ivTable Spec.Blake2B); [@inline_let] let ivTable: (x:glbuffer (Spec.pub_word_t a) 8ul{witnessed x (Spec.ivTable a) /\ recallable x}) = match a with | Spec.Blake2S -> ivTable_S | Spec.Blake2B -> ivTable_B in let r = index ivTable s in secret #(Spec.wt a) r inline_for_extraction noextract val get_sigma: s: size_t{v s < 160} -> Stack Spec.sigma_elt_t (requires (fun h -> True)) (ensures (fun h0 z h1 -> h0 == h1 /\ z == Lib.Sequence.(Spec.sigmaTable.[v s]))) let get_sigma s = recall_contents sigmaTable Spec.sigmaTable; index sigmaTable s inline_for_extraction noextract val get_sigma_sub: start: size_t -> i: size_t{v i < 16 /\ v start + v i < 160} -> Stack Spec.sigma_elt_t (requires (fun h -> True)) (ensures (fun h0 z h1 -> h0 == h1 /\ v z == v (Seq.index Spec.sigmaTable (v start + v i)))) let get_sigma_sub start i = get_sigma (start +. i) inline_for_extraction noextract let rounds_t (a:Spec.alg): size_t = size (Spec.rounds a) inline_for_extraction noextract val size_to_word: al:Spec.alg -> s:size_t -> u:word_t al{u == Spec.nat_to_word al (v s)} let size_to_word al s = match al with | Spec.Blake2S -> size_to_uint32 s | Spec.Blake2B -> size_to_uint64 s inline_for_extraction noextract val size_to_limb: al:Spec.alg -> s:size_t -> u:Spec.limb_t al{u == Spec.nat_to_limb al (v s)} let size_to_limb al s = match al with | Spec.Blake2S -> size_to_uint64 s | Spec.Blake2B -> to_u128 (size_to_uint64 s) /// Constants /// Define algorithm functions inline_for_extraction noextract val g1: #al:Spec.alg -> #m:m_spec -> wv:state_p al m -> a:index_t -> b:index_t -> r:rotval (Spec.wt al) -> Stack unit (requires (fun h -> live h wv /\ a <> b)) (ensures (fun h0 _ h1 -> modifies (loc wv) h0 h1 /\ (state_v h1 wv) == Spec.g1 al (state_v h0 wv) (v a) (v b) r)) let g1 #al #m wv a b r = let h0 = ST.get() in let wv_a = rowi wv a in let wv_b = rowi wv b in xor_row wv_a wv_b; ror_row wv_a r; let h2 = ST.get() in Lib.Sequence.eq_intro (state_v h2 wv) (Spec.g1 al (state_v h0 wv) (v a) (v b) r) #push-options "--z3rlimit 100 --max_fuel 1 --max_ifuel 1" inline_for_extraction noextract val g2: #al:Spec.alg -> #m:m_spec -> wv:state_p al m -> a:index_t -> b:index_t -> x:row_p al m -> Stack unit (requires (fun h -> live h wv /\ live h x /\ disjoint wv x /\ a <> b)) (ensures (fun h0 _ h1 -> modifies (loc wv) h0 h1 /\ state_v h1 wv == Spec.g2 al (state_v h0 wv) (v a) (v b) (row_v h0 x))) let g2 #al #m wv a b x = let h0 = ST.get() in let wv_a = rowi wv a in let wv_b = rowi wv b in add_row wv_a wv_b; add_row wv_a x; let h1 = ST.get() in Lib.Sequence.eq_intro (state_v h1 wv) (Spec.g2 al (state_v h0 wv) (v a) (v b) (row_v h0 x)) #push-options "--z3rlimit 100 --max_fuel 1 --max_ifuel 1" inline_for_extraction noextract val g2z: #al:Spec.alg -> #m:m_spec -> wv:state_p al m -> a:index_t -> b:index_t -> Stack unit (requires (fun h -> live h wv /\ a <> b)) (ensures (fun h0 _ h1 -> modifies (loc wv) h0 h1 /\ state_v h1 wv == Spec.g2z al (state_v h0 wv) (v a) (v b))) let g2z #al #m wv a b = let h0 = ST.get() in let wv_a = rowi wv a in let wv_b = rowi wv b in add_row wv_a wv_b; let h1 = ST.get() in Lib.Sequence.eq_intro (state_v h1 wv) (Spec.g2z al (state_v h0 wv) (v a) (v b)) inline_for_extraction noextract val blake2_mixing : #al:Spec.alg -> #m:m_spec -> wv:state_p al m -> x:row_p al m -> y:row_p al m -> Stack unit (requires (fun h -> live h wv /\ live h x /\ live h y /\ disjoint wv x /\ disjoint wv y)) (ensures (fun h0 _ h1 -> modifies (loc wv) h0 h1 /\ state_v h1 wv == Spec.blake2_mixing al (state_v h0 wv) (row_v h0 x) (row_v h0 y))) let blake2_mixing #al #m wv x y = let h0 = ST.get() in push_frame (); let a = 0ul in let b = 1ul in let c = 2ul in let d = 3ul in [@inline_let] let r0 = normalize_term (Lib.Sequence.index (Spec.rTable al) 0) in normalize_term_spec (Lib.Sequence.index (Spec.rTable al) 0); [@inline_let] let r1 = normalize_term (Lib.Sequence.index (Spec.rTable al) 1) in normalize_term_spec (Lib.Sequence.index (Spec.rTable al) 1); [@inline_let] let r2 = normalize_term (Lib.Sequence.index (Spec.rTable al) 2) in normalize_term_spec (Lib.Sequence.index (Spec.rTable al) 2); [@inline_let] let r3 = normalize_term (Lib.Sequence.index (Spec.rTable al) 3) in normalize_term_spec (Lib.Sequence.index (Spec.rTable al) 3); let h1 = ST.get() in g2 wv a b x; g1 wv d a r0; g2z wv c d; g1 wv b c r1; g2 wv a b y; g1 wv d a r2; g2z wv c d; g1 wv b c r3; let h2 = ST.get() in pop_frame (); let h3 = ST.get() in assert(modifies (loc wv) h0 h3); Lib.Sequence.eq_intro (state_v h2 wv) (Spec.blake2_mixing al (state_v h1 wv) (row_v h1 x) (row_v h1 y)) #pop-options inline_for_extraction noextract val diag: #a:Spec.alg -> #m:m_spec -> wv:state_p a m -> Stack unit (requires (fun h -> live h wv)) (ensures (fun h0 _ h1 -> modifies (loc wv) h0 h1 /\ state_v h1 wv == Spec.diag (state_v h0 wv))) let diag #a #m wv = let r1 = rowi wv 1ul in let r2 = rowi wv 2ul in let r3 = rowi wv 3ul in let h0 = ST.get() in permr_row r1 1ul; permr_row r2 2ul; permr_row r3 3ul inline_for_extraction noextract val undiag: #a:Spec.alg -> #m:m_spec -> wv:state_p a m -> Stack unit (requires (fun h -> live h wv)) (ensures (fun h0 _ h1 -> modifies (loc wv) h0 h1 /\ state_v h1 wv == Spec.undiag (state_v h0 wv))) let undiag #a #m wv = let r1 = rowi wv 1ul in let r2 = rowi wv 2ul in let r3 = rowi wv 3ul in let h0 = ST.get() in permr_row r1 3ul; permr_row r2 2ul; permr_row r3 1ul inline_for_extraction noextract val gather_state: #a:Spec.alg -> #ms:m_spec -> st:state_p a ms -> m:block_w a -> start:size_t{v start <= 144} -> Stack unit (requires (fun h -> live h st /\ live h m /\ disjoint st m)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ state_v h1 st == Spec.gather_state a (as_seq h0 m) (v start))) inline_for_extraction noextract let get_sigma' (start: size_t { v start <= 144 }) (i: size_t { normalize (i <=. 15ul) }): Stack Spec.sigma_elt_t (requires (fun h -> True)) (ensures (fun h0 z h1 -> h0 == h1 /\ z == Lib.Sequence.(Spec.sigmaTable.[v start + v i]))) = get_sigma (start +! i) #push-options "--z3rlimit 500" let gather_state #a #ms st m start = let h0 = ST.get() in let r0 = rowi st 0ul in let r1 = rowi st 1ul in let r2 = rowi st 2ul in let r3 = rowi st 3ul in let s0 = get_sigma' start 0ul in let s1 = get_sigma' start 1ul in let s2 = get_sigma' start 2ul in let s3 = get_sigma' start 3ul in let s4 = get_sigma' start 4ul in let s5 = get_sigma' start 5ul in let s6 = get_sigma' start 6ul in let s7 = get_sigma' start 7ul in let s8 = get_sigma' start 8ul in let s9 = get_sigma' start 9ul in let s10 = get_sigma' start 10ul in let s11 = get_sigma' start 11ul in let s12 = get_sigma' start 12ul in let s13 = get_sigma' start 13ul in let s14 = get_sigma' start 14ul in let s15 = get_sigma' start 15ul in let h1 = ST.get() in gather_row r0 m s0 s2 s4 s6; let h2 = ST.get() in gather_row r1 m s1 s3 s5 s7; let h3 = ST.get() in gather_row r2 m s8 s10 s12 s14; let h4 = ST.get() in gather_row r3 m s9 s11 s13 s15; let h5 = ST.get() in assert(modifies (loc st) h0 h5); Lib.Sequence.eq_intro (state_v h5 st) (Spec.gather_state a (as_seq h0 m) (v start)) inline_for_extraction noextract val blake2_round : #al:Spec.alg -> #ms:m_spec -> wv:state_p al ms -> m:block_w al -> i:size_t -> Stack unit (requires (fun h -> live h wv /\ live h m /\ disjoint wv m)) (ensures (fun h0 _ h1 -> modifies (loc wv) h0 h1 /\ state_v h1 wv == Spec.blake2_round al (as_seq h0 m) (v i) (state_v h0 wv))) let blake2_round #al #ms wv m i = push_frame(); let start_idx = (i %. size 10) *. size 16 in assert (v start_idx == (v i % 10) * 16); assert (v start_idx <= 144); let m_st = alloc_state al ms in gather_state m_st m start_idx; let x = rowi m_st 0ul in let y = rowi m_st 1ul in let z = rowi m_st 2ul in let w = rowi m_st 3ul in let h1 = ST.get() in assert (disjoint wv m_st); assert (disjoint m_st wv); assert (disjoint x wv); assert (disjoint wv x); assert (disjoint y wv); assert (disjoint wv y); assert (disjoint z wv); assert (disjoint wv z); assert (disjoint w wv); assert (disjoint wv w); blake2_mixing wv x y; diag wv; blake2_mixing wv z w; undiag wv; pop_frame () inline_for_extraction noextract val blake2_compress0: #al:Spec.alg -> m_s: block_p al -> m_w: block_w al -> Stack unit (requires (fun h -> live h m_s /\ live h m_w /\ disjoint m_s m_w)) (ensures (fun h0 _ h1 -> modifies (loc m_w) h0 h1 /\ as_seq h1 m_w == Spec.blake2_compress0 al (as_seq h0 m_s))) let blake2_compress0 #al m_s m_w = uints_from_bytes_le m_w m_s inline_for_extraction noextract val blake2_compress1: #al:Spec.alg -> #m:m_spec -> wv: state_p al m -> s_iv: state_p al m -> offset: Spec.limb_t al -> flag: bool -> Stack unit (requires (fun h -> live h wv /\ live h s_iv /\ disjoint wv s_iv)) (ensures (fun h0 _ h1 -> modifies (loc wv) h0 h1 /\ state_v h1 wv == Spec.blake2_compress1 al (state_v h0 s_iv) offset flag)) let blake2_compress1 #al #m wv s_iv offset flag = let h0 = ST.get() in push_frame(); let mask = alloc_row al m in [@inline_let] let wv_12 = Spec.limb_to_word al offset in [@inline_let] let wv_13 = Spec.limb_to_word al (offset >>. (size (bits (Spec.wt al)))) in // SH: TODO: for some reason, ``ones`` below doesn't get inlined by KaRaMeL, // causing an extraction problem. The 3 lines below are a hack to fix // extraction for the time being: // [> let wv_14 = if flag then (ones (Spec.wt al) SEC) else (Spec.zero al) in // After investigation, it is because ones is [@(strict_on_arguments [0])], // and so isn't unfolded if its first argument is not normalized to a constant. // However, the first argument should always be normalized (I checked the // output generated by KaRaMeL and the definitions). (**) normalize_term_spec (Spec.wt al); [@inline_let] let wt_al = normalize_term (Spec.wt al) in let wv_14 = if flag then ones wt_al SEC else (Spec.zero al) in // end of the TODO let wv_15 = Spec.zero al in create_row mask wv_12 wv_13 wv_14 wv_15; copy_state wv s_iv; let wv3 = rowi wv 3ul in xor_row wv3 mask; pop_frame(); let h1 = ST.get() in assert(modifies (loc wv) h0 h1); Lib.Sequence.eq_intro (state_v h1 wv) (Spec.blake2_compress1 al (state_v h0 s_iv) offset flag) inline_for_extraction noextract val blake2_compress2 : #al:Spec.alg -> #ms:m_spec -> wv: state_p al ms -> m: block_w al -> Stack unit (requires (fun h -> live h wv /\ live h m /\ disjoint wv m)) (ensures (fun h0 _ h1 -> modifies1 wv h0 h1 /\ state_v h1 wv == Spec.blake2_compress2 al (state_v h0 wv) (as_seq h0 m))) #push-options "--z3rlimit 400" let blake2_compress2 #al #ms wv m = let h0 = ST.get () in [@inline_let] let a_spec = Spec.state al in [@inline_let] let refl h = state_v h wv in [@inline_let] let footprint = Ghost.hide(loc wv) in [@inline_let] let spec h = Spec.blake2_round al h.[|m|] in loop_refl h0 (rounds_t al) a_spec refl footprint spec (fun i -> Loops.unfold_repeati (Spec.rounds al) (spec h0) (state_v h0 wv) (v i); blake2_round wv m i) #pop-options inline_for_extraction noextract val blake2_compress3 : #al:Spec.alg -> #ms:m_spec -> s_iv:state_p al ms -> wv:state_p al ms -> Stack unit (requires (fun h -> live h s_iv /\ live h wv /\ disjoint s_iv wv)) (ensures (fun h0 _ h1 -> modifies (loc s_iv) h0 h1 /\ state_v h1 s_iv == Spec.blake2_compress3 al (state_v h0 wv) (state_v h0 s_iv))) let blake2_compress3 #al #ms s_iv wv = let h0 = ST.get() in let s0 = rowi s_iv 0ul in let s1 = rowi s_iv 1ul in let r0 = rowi wv 0ul in let r1 = rowi wv 1ul in let r2 = rowi wv 2ul in let r3 = rowi wv 3ul in assert (disjoint s0 wv); assert (disjoint wv s0); assert (disjoint s1 wv); assert (disjoint wv s1); assert (disjoint r0 s0); assert (disjoint r2 s0); assert (disjoint r1 s1); assert (disjoint r3 s1); xor_row s0 r0; let h1 = ST.get() in xor_row s0 r2; let h2 = ST.get() in xor_row s1 r1; let h3 = ST.get() in xor_row s1 r3; let h4 = ST.get() in assert (modifies (loc s_iv) h0 h4); let open Lib.Sequence in assert (row_v h0 r0 == (state_v h0 wv).[0]); assert (row_v h1 r2 == (state_v h0 wv).[2]); assert (row_v h4 s0 == Spec.(((state_v h0 s_iv).[0] ^| (state_v h0 wv).[0]) ^| (state_v h0 wv).[2])); assert (row_v h4 s1 == Spec.(((state_v h0 s_iv).[1] ^| (state_v h0 wv).[1]) ^| (state_v h0 wv).[3])); eq_intro (state_v h2 s_iv) ((state_v h0 s_iv).[0] <- row_v h4 s0); eq_intro (state_v h4 s_iv) ((state_v h2 s_iv).[1] <- row_v h4 s1); eq_intro (state_v h4 s_iv) (Spec.blake2_compress3 al (state_v h0 wv) (state_v h0 s_iv)) inline_for_extraction noextract let compress_t (al:Spec.alg) (ms:m_spec) = wv:state_p al ms -> s: state_p al ms -> m: block_p al -> offset: Spec.limb_t al -> flag: bool -> Stack unit (requires (fun h -> live h wv /\ live h s /\ live h m /\ disjoint s m /\ disjoint wv s /\ disjoint wv m)) (ensures (fun h0 _ h1 -> modifies (loc s |+| loc wv) h0 h1 /\ state_v h1 s == Spec.blake2_compress al (state_v h0 s) h0.[|m|] offset flag)) inline_for_extraction noextract val blake2_compress: #al:Spec.alg -> #ms:m_spec -> compress_t al ms let blake2_compress #al #ms wv s m offset flag = push_frame(); let m_w = create 16ul (Spec.zero al) in blake2_compress0 #al m m_w; blake2_compress1 wv s offset flag; blake2_compress2 wv m_w; blake2_compress3 s wv; pop_frame() inline_for_extraction noextract let blake2_update_block_st (al:Spec.alg) (ms:m_spec) = wv:state_p al ms -> hash: state_p al ms -> flag: bool -> totlen: Spec.limb_t al{v totlen <= Spec.max_limb al} -> d: block_p al -> Stack unit (requires (fun h -> live h wv /\ live h hash /\ live h d /\ disjoint hash d /\ disjoint wv hash /\ disjoint wv d)) (ensures (fun h0 _ h1 -> modifies (loc hash |+| loc wv) h0 h1 /\ state_v h1 hash == Spec.blake2_update_block al flag (v totlen) h0.[|d|] (state_v h0 hash))) inline_for_extraction noextract val blake2_update_block: #al:Spec.alg -> #ms:m_spec -> blake2_update_block_st al ms let blake2_update_block #al #ms wv hash flag totlen d = blake2_compress wv hash d totlen flag inline_for_extraction noextract let blake2_update1_st (al:Spec.alg) (ms:m_spec) = #len:size_t -> wv: state_p al ms -> hash: state_p al ms -> prev: Spec.limb_t al{v prev + v len <= Spec.max_limb al} -> d: lbuffer uint8 len -> i: size_t{v i < length d / Spec.size_block al} -> Stack unit (requires (fun h -> live h wv /\ live h hash /\ live h d /\ disjoint hash d /\ disjoint wv hash /\ disjoint wv d)) (ensures (fun h0 _ h1 -> modifies (loc hash |+| loc wv) h0 h1 /\ state_v h1 hash == Spec.blake2_update1 al (v prev) h0.[|d|] (v i) (state_v h0 hash))) inline_for_extraction noextract val blake2_update1: #al:Spec.alg -> #ms:m_spec -> blake2_update_block: blake2_update_block_st al ms -> blake2_update1_st al ms let blake2_update1 #al #ms blake2_update_block #len wv hash prev d i = let totlen = prev +. size_to_limb al ((i+!1ul) *! size_block al) in assert (v totlen == v prev + (v i + 1) * Spec.size_block al); let b = sub d (i *. size_block al) (size_block al) in let h = ST.get() in assert (as_seq h b == Spec.get_blocki al (as_seq h d) (v i)); blake2_update_block wv hash false totlen b inline_for_extraction noextract let blake2_update_last_st (al:Spec.alg) (ms:m_spec) = #len:size_t -> wv: state_p al ms -> hash: state_p al ms -> prev: Spec.limb_t al{v prev + v len <= Spec.max_limb al} -> rem: size_t {v rem <= v len /\ v rem <= Spec.size_block al} -> d: lbuffer uint8 len -> Stack unit (requires (fun h -> live h wv /\ live h hash /\ live h d /\ disjoint hash d /\ disjoint wv hash /\ disjoint wv d)) (ensures (fun h0 _ h1 -> modifies (loc hash |+| loc wv) h0 h1 /\ state_v h1 hash == Spec.blake2_update_last al (v prev) (v rem) h0.[|d|] (state_v h0 hash))) inline_for_extraction noextract val blake2_update_last: #al:Spec.alg -> #ms:m_spec -> blake2_update_block: blake2_update_block_st al ms -> blake2_update_last_st al ms let blake2_update_last #al #ms blake2_update_block #len wv hash prev rem d = let h0 = ST.get () in [@inline_let] let spec _ h1 = state_v h1 hash == Spec.blake2_update_last al (v prev) (v rem) h0.[|d|] (state_v h0 hash) in salloc1 h0 (size_block al) (u8 0) (Ghost.hide (loc hash |+| loc wv)) spec (fun last_block -> let last = sub d (len -! rem) rem in let h1 = ST.get() in update_sub last_block 0ul rem last; let h2 = ST.get() in as_seq_gsub h1 d (len -! rem) rem; assert (as_seq h1 last == Seq.sub (as_seq h1 d) (v len - v rem) (v rem)); assert (as_seq h1 last == Seq.slice (as_seq h0 d) (v len - v rem) (v len)); assert (as_seq h2 last_block == Spec.get_last_padded_block al (as_seq h0 d) (v rem)); let totlen = prev +. (size_to_limb al len) in blake2_update_block wv hash true totlen last_block; let h3 = ST.get() in assert (v totlen == v prev + v len); assert (state_v h3 hash == Spec.blake2_update_block al true (v totlen) (as_seq h2 last_block) (state_v h0 hash))) inline_for_extraction noextract let blake2_init_st (al:Spec.alg) (ms:m_spec) = hash: state_p al ms -> kk: size_t{v kk <= Spec.max_key al} -> nn: size_t{1 <= v nn /\ v nn <= Spec.max_output al} -> Stack unit (requires (fun h -> live h hash)) (ensures (fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ state_v h1 hash == Spec.blake2_init_hash al (Spec.blake2_default_params al) (v kk) (v nn))) inline_for_extraction noextract val serialize_params (al:Spec.alg) (kk:size_t{v kk <= Spec.max_key al}) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output al}) (p: blake2_params al) (b: lbuffer (word_t al) 8ul) : Stack unit (requires fun h -> live h b /\ blake2_params_inv h p /\ LowStar.Buffer.loc_disjoint (loc b) (blake2_params_loc p) /\ as_seq h b == Seq.create 8 (Spec.nat_to_word al 0) ) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Spec.serialize_blake2_params (Spec.set_key_length (Spec.set_digest_length (blake2_params_v h0 p) (v nn)) (v kk))) #push-options "--z3rlimit 100 --fuel 0" inline_for_extraction noextract let serialize_params_blake2s (kk:size_t{v kk <= Spec.max_key Spec.Blake2S}) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S}) (p: blake2_params Spec.Blake2S) (b: lbuffer (word_t Spec.Blake2S) 8ul) : Stack unit (requires fun h -> live h b /\ blake2_params_inv h p /\ LowStar.Buffer.loc_disjoint (loc b) (blake2_params_loc p) /\ as_seq h b == Seq.create 8 (u32 0) ) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Spec.serialize_blake2_params (Spec.set_key_length (Spec.set_digest_length (blake2_params_v h0 p) (v nn)) (v kk))) = let h0 = ST.get () in [@inline_let] let kk_shift_8 = shift_left (to_u32 kk) (size 8) in [@inline_let] let fanout_shift_16 = shift_left (to_u32 p.fanout) (size 16) in [@inline_let] let depth_shift_24 = shift_left (to_u32 p.depth) (size 24) in [@inline_let] let v0 = (to_u32 nn) ^. kk_shift_8 ^. fanout_shift_16 ^. depth_shift_24 in [@inline_let] let v1 = p.leaf_length in [@inline_let] let v2 = p.node_offset in [@inline_let] let node_depth_shift_16 = shift_left (to_u32 p.node_depth) (size 16) in [@inline_let] let inner_length_shift_16 = shift_left (to_u32 p.inner_length) (size 24) in [@inline_let] let v3 = (to_u32 p.xof_length) ^. node_depth_shift_16 ^. inner_length_shift_16 in uints_from_bytes_le (sub b 4ul 2ul) p.salt; uints_from_bytes_le (sub b 6ul 2ul) p.personal; // AF: Putting these writes *after* modifications on a subbuffer of b helps with modifies-reasoning: // By putting them before, F* struggles with proving that b[0..3] is not modified by uints_from_bytes_le b.(0ul) <- v0; b.(1ul) <- v1; b.(2ul) <- v2; b.(3ul) <- v3; let h1 = ST.get () in let aux () : Lemma (as_seq h1 b `Seq.equal` Spec.serialize_blake2s_params (Spec.set_key_length (Spec.set_digest_length (blake2_params_v h0 p) (v nn)) (v kk))) = let open Lib.Sequence in let open Lib.ByteSequence in let s0 = (u32 (v nn)) ^. (u32 (v kk) <<. (size 8)) ^. (u32 (v p.fanout) <<. (size 16)) ^. (u32 (v p.depth) <<. (size 24)) in let s1 = p.leaf_length in let s2 = p.node_offset in let s3 = (u32 (v p.xof_length)) ^. (u32 (v p.node_depth) <<. (size 16)) ^. (u32 (v p.inner_length) <<. (size 24)) in let salt_u32: lseq uint32 2 = uints_from_bytes_le (as_seq h0 (get_salt p)) in let s4 = salt_u32.[0] in let s5 = salt_u32.[1] in let personal_u32: lseq uint32 2 = uints_from_bytes_le (as_seq h0 (get_personal p)) in let s6 = personal_u32.[0] in let s7 = personal_u32.[1] in [@inline_let] let l = [s0; s1; s2; s3; s4; s5; s6; s7] in assert_norm (List.Tot.length l == 8); // There seems to be something not triggering with createL, requiring the // following lemma calls, and assert_norms to relate List.index to the // actual elements assert_norm (List.Tot.index l 0 == s0); assert_norm (List.Tot.index l 1 == s1); assert_norm (List.Tot.index l 2 == s2); assert_norm (List.Tot.index l 3 == s3); assert_norm (List.Tot.index l 4 == s4); assert_norm (List.Tot.index l 5 == s5); assert_norm (List.Tot.index l 6 == s6); assert_norm (List.Tot.index l 7 == s7); of_list_index l 0; of_list_index l 1; of_list_index l 2; of_list_index l 3; of_list_index l 4; of_list_index l 5; of_list_index l 6; of_list_index l 7 in aux()
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "Hacl.Impl.Blake2.Constants.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Generic.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.Blake2.Core", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Blake2.Constants", "short_module": null }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Blake2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Blake2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
kk: Lib.IntTypes.size_t {Lib.IntTypes.v kk <= Spec.Blake2.Definitions.max_key Spec.Blake2.Definitions.Blake2B} -> nn: Lib.IntTypes.size_t { 1 <= Lib.IntTypes.v nn /\ Lib.IntTypes.v nn <= Spec.Blake2.Definitions.max_output Spec.Blake2.Definitions.Blake2B } -> p: Hacl.Impl.Blake2.Core.blake2_params Spec.Blake2.Definitions.Blake2B -> b: Lib.Buffer.lbuffer (Hacl.Impl.Blake2.Core.word_t Spec.Blake2.Definitions.Blake2B) 8ul -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Spec.Blake2.Definitions.max_key", "Spec.Blake2.Definitions.Blake2B", "Prims.l_and", "Spec.Blake2.Definitions.max_output", "Hacl.Impl.Blake2.Core.blake2_params", "Lib.Buffer.lbuffer", "Hacl.Impl.Blake2.Core.word_t", "FStar.UInt32.__uint_to_t", "Prims.unit", "Prims.l_True", "Prims.squash", "Lib.Sequence.equal", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Spec.Blake2.serialize_blake2b_params", "Spec.Blake2.Definitions.set_key_length", "Spec.Blake2.Definitions.set_digest_length", "Hacl.Impl.Blake2.Core.blake2_params_v", "Prims.Nil", "FStar.Pervasives.pattern", "Lib.Sequence.of_list_index", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Pervasives.assert_norm", "Prims.eq2", "FStar.List.Tot.Base.index", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "Prims.Cons", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Sequence.op_String_Access", "Lib.Sequence.lseq", "Lib.ByteSequence.uints_from_bytes_le", "Lib.IntTypes.uint8", "Hacl.Impl.Blake2.Core.personal_len", "Hacl.Impl.Blake2.Core.get_personal", "Hacl.Impl.Blake2.Core.salt_len", "Hacl.Impl.Blake2.Core.get_salt", "Lib.IntTypes.range", "Lib.IntTypes.u64", "Lib.IntTypes.op_Hat_Dot", "Lib.IntTypes.U8", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__node_depth", "Lib.IntTypes.op_Less_Less_Dot", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__inner_length", "Lib.IntTypes.size", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__node_offset", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__xof_length", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__fanout", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__depth", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__leaf_length", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.op_Array_Assignment", "Lib.ByteBuffer.uints_from_bytes_le", "Spec.Blake2.Definitions.wt", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__personal", "Lib.Buffer.lbuffer_t", "Lib.Buffer.sub", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__salt", "Lib.IntTypes.to_u64", "Lib.IntTypes.shift_left", "Lib.Buffer.live", "Hacl.Impl.Blake2.Core.blake2_params_inv", "LowStar.Monotonic.Buffer.loc_disjoint", "Lib.Buffer.loc", "Hacl.Impl.Blake2.Core.blake2_params_loc", "Lib.Sequence.create", "Lib.Buffer.modifies", "Spec.Blake2.serialize_blake2_params" ]
[]
false
true
false
false
false
let serialize_params_blake2b (kk: size_t{v kk <= Spec.max_key Spec.Blake2B}) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2B}) (p: blake2_params Spec.Blake2B) (b: lbuffer (word_t Spec.Blake2B) 8ul) : Stack unit (requires fun h -> live h b /\ blake2_params_inv #Spec.Blake2B h p /\ LowStar.Buffer.loc_disjoint (loc b) (blake2_params_loc p) /\ as_seq h b == Seq.create 8 (u64 0)) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Spec.serialize_blake2_params (Spec.set_key_length (Spec.set_digest_length (blake2_params_v h0 p) (v nn)) (v kk))) =
let h0 = ST.get () in [@@ inline_let ]let kk_shift_8 = shift_left (to_u64 kk) (size 8) in [@@ inline_let ]let fanout_shift_16 = shift_left (to_u64 p.fanout) (size 16) in [@@ inline_let ]let depth_shift_24 = shift_left (to_u64 p.depth) (size 24) in [@@ inline_let ]let leaf_length_shift_32 = shift_left (to_u64 p.leaf_length) (size 32) in [@@ inline_let ]let v0 = (to_u64 nn) ^. kk_shift_8 ^. fanout_shift_16 ^. depth_shift_24 ^. leaf_length_shift_32 in [@@ inline_let ]let xof_length_shift_32 = shift_left (to_u64 p.xof_length) (size 32) in [@@ inline_let ]let v1 = (to_u64 p.node_offset) ^. xof_length_shift_32 in [@@ inline_let ]let inner_length_shift_8 = shift_left (to_u64 p.inner_length) (size 8) in [@@ inline_let ]let v2 = (to_u64 p.node_depth) ^. inner_length_shift_8 in uints_from_bytes_le (sub b 4ul 2ul) p.salt; uints_from_bytes_le (sub b 6ul 2ul) p.personal; b.(0ul) <- v0; b.(1ul) <- v1; b.(2ul) <- v2; b.(3ul) <- (u64 0); let h1 = ST.get () in let aux () : Lemma ((as_seq h1 b) `Seq.equal` (Spec.serialize_blake2b_params (Spec.set_key_length (Spec.set_digest_length (blake2_params_v h0 p) (v nn)) (v kk)))) = let open Lib.Sequence in let open Lib.ByteSequence in let s0 = (u64 (v nn)) ^. (u64 (v kk) <<. (size 8)) ^. (u64 (v p.fanout) <<. (size 16)) ^. (u64 (v p.depth) <<. (size 24)) ^. (u64 (v p.leaf_length) <<. (size 32)) in let s1 = (u64 (v p.node_offset)) ^. (u64 (v p.xof_length) <<. (size 32)) in let s2 = (u64 (v p.node_depth)) ^. (u64 (v p.inner_length) <<. (size 8)) in let s3 = u64 0 in let salt_u64:lseq uint64 2 = uints_from_bytes_le (as_seq h0 (get_salt p)) in let s4 = salt_u64.[ 0 ] in let s5 = salt_u64.[ 1 ] in let personal_u64:lseq uint64 2 = uints_from_bytes_le (as_seq h0 (get_personal p)) in let s6 = personal_u64.[ 0 ] in let s7 = personal_u64.[ 1 ] in [@@ inline_let ]let l = [s0; s1; s2; s3; s4; s5; s6; s7] in assert_norm (List.Tot.length l == 8); assert_norm (List.Tot.index l 0 == s0); assert_norm (List.Tot.index l 1 == s1); assert_norm (List.Tot.index l 2 == s2); assert_norm (List.Tot.index l 3 == s3); assert_norm (List.Tot.index l 4 == s4); assert_norm (List.Tot.index l 5 == s5); assert_norm (List.Tot.index l 6 == s6); assert_norm (List.Tot.index l 7 == s7); of_list_index l 0; of_list_index l 1; of_list_index l 2; of_list_index l 3; of_list_index l 4; of_list_index l 5; of_list_index l 6; of_list_index l 7 in aux ()
false
FStar.Char.fsti
FStar.Char.int_of_char
val int_of_char (c: char) : nat
val int_of_char (c: char) : nat
let int_of_char (c: char) : nat = U32.v (u32_of_char c)
{ "file_name": "ulib/FStar.Char.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 55, "end_line": 56, "start_col": 0, "start_line": 56 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Char /// This module provides the [char] type, an abstract type /// representing UTF-8 characters. /// /// UTF-8 characters are representing in a variable-length encoding of /// between 1 and 4 bytes, with a maximum of 21 bits used to represent /// a code. /// /// See https://en.wikipedia.org/wiki/UTF-8 and /// https://erratique.ch/software/uucp/doc/unicode.html module U32 = FStar.UInt32 (** [char] is a new primitive type with decidable equality *) new val char:eqtype (** A [char_code] is the representation of a UTF-8 char code in an unsigned 32-bit integer whose value is at most 0x110000, and not between 0xd800 and 0xe000 *) type char_code = n: U32.t{U32.v n < 0xd7ff \/ (U32.v n >= 0xe000 /\ U32.v n <= 0x10ffff)} (** A primitive to extract the [char_code] of a [char] *) val u32_of_char: char -> Tot char_code (** A primitive to promote a [char_code] to a [char] *) val char_of_u32: char_code -> Tot char (** Encoding and decoding from [char] to [char_code] is the identity *) val char_of_u32_of_char (c: char) : Lemma (ensures (char_of_u32 (u32_of_char c) == c)) [SMTPat (u32_of_char c)] (** Encoding and decoding from [char] to [char_code] is the identity *) val u32_of_char_of_u32 (c: char_code) : Lemma (ensures (u32_of_char (char_of_u32 c) == c)) [SMTPat (char_of_u32 c)] (** A couple of utilities to use mathematical integers rather than [U32.t]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Char.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: FStar.Char.char -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "FStar.Char.char", "FStar.UInt32.v", "FStar.Char.u32_of_char", "Prims.nat" ]
[]
false
false
false
true
false
let int_of_char (c: char) : nat =
U32.v (u32_of_char c)
false
FStar.Char.fsti
FStar.Char.char_of_int
val char_of_int (i: nat{i < 0xd7ff \/ (i >= 0xe000 /\ i <= 0x10ffff)}) : char
val char_of_int (i: nat{i < 0xd7ff \/ (i >= 0xe000 /\ i <= 0x10ffff)}) : char
let char_of_int (i: nat{i < 0xd7ff \/ (i >= 0xe000 /\ i <= 0x10ffff)}) : char = char_of_u32 (U32.uint_to_t i)
{ "file_name": "ulib/FStar.Char.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 109, "end_line": 57, "start_col": 0, "start_line": 57 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Char /// This module provides the [char] type, an abstract type /// representing UTF-8 characters. /// /// UTF-8 characters are representing in a variable-length encoding of /// between 1 and 4 bytes, with a maximum of 21 bits used to represent /// a code. /// /// See https://en.wikipedia.org/wiki/UTF-8 and /// https://erratique.ch/software/uucp/doc/unicode.html module U32 = FStar.UInt32 (** [char] is a new primitive type with decidable equality *) new val char:eqtype (** A [char_code] is the representation of a UTF-8 char code in an unsigned 32-bit integer whose value is at most 0x110000, and not between 0xd800 and 0xe000 *) type char_code = n: U32.t{U32.v n < 0xd7ff \/ (U32.v n >= 0xe000 /\ U32.v n <= 0x10ffff)} (** A primitive to extract the [char_code] of a [char] *) val u32_of_char: char -> Tot char_code (** A primitive to promote a [char_code] to a [char] *) val char_of_u32: char_code -> Tot char (** Encoding and decoding from [char] to [char_code] is the identity *) val char_of_u32_of_char (c: char) : Lemma (ensures (char_of_u32 (u32_of_char c) == c)) [SMTPat (u32_of_char c)] (** Encoding and decoding from [char] to [char_code] is the identity *) val u32_of_char_of_u32 (c: char_code) : Lemma (ensures (u32_of_char (char_of_u32 c) == c)) [SMTPat (char_of_u32 c)] (** A couple of utilities to use mathematical integers rather than [U32.t] to represent a [char_code] *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Char.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: Prims.nat{i < 0xd7ff \/ i >= 0xe000 /\ i <= 0x10ffff} -> FStar.Char.char
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_or", "Prims.b2t", "Prims.op_LessThan", "Prims.l_and", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThanOrEqual", "FStar.Char.char_of_u32", "FStar.UInt32.uint_to_t", "FStar.Char.char" ]
[]
false
false
false
false
false
let char_of_int (i: nat{i < 0xd7ff \/ (i >= 0xe000 /\ i <= 0x10ffff)}) : char =
char_of_u32 (U32.uint_to_t i)
false
DependentBoolRefinement.fst
DependentBoolRefinement.open_exp_freevars
val open_exp_freevars (e v: src_exp) (n: nat) : Lemma (ensures ((freevars e) `Set.subset` (freevars (open_exp' e v n))) /\ ((freevars (open_exp' e v n)) `Set.subset` ((freevars e) `Set.union` (freevars v)))) (decreases e)
val open_exp_freevars (e v: src_exp) (n: nat) : Lemma (ensures ((freevars e) `Set.subset` (freevars (open_exp' e v n))) /\ ((freevars (open_exp' e v n)) `Set.subset` ((freevars e) `Set.union` (freevars v)))) (decreases e)
let rec open_exp_freevars (e:src_exp) (v:src_exp) (n:nat) : Lemma (ensures (freevars e `Set.subset` freevars (open_exp' e v n)) /\ (freevars (open_exp' e v n) `Set.subset` (freevars e `Set.union` freevars v))) (decreases e) // [SMTPat (freevars (open_exp' e v n))] = match e with | EBool _ | EBVar _ | EVar _ -> () | EApp e1 e2 -> open_exp_freevars e1 v n; open_exp_freevars e2 v n | EIf b e1 e2 -> open_exp_freevars b v n; open_exp_freevars e1 v n; open_exp_freevars e2 v n | ELam t e -> open_ty_freevars t v n; open_exp_freevars e v (n + 1) and open_ty_freevars (t:src_ty) (v:src_exp) (n:nat) : Lemma (ensures (freevars_ty t `Set.subset` freevars_ty (open_ty' t v n)) /\ (freevars_ty (open_ty' t v n) `Set.subset` (freevars_ty t `Set.union` freevars v))) (decreases t) // [SMTPat (freevars_ty (open_ty' t v n))] = match t with | TBool -> () | TArrow t1 t2 -> open_ty_freevars t1 v n; open_ty_freevars t2 v (n + 1) | TRefineBool e -> open_exp_freevars e v (n + 1)
{ "file_name": "examples/dsls/dependent_bool_refinement/DependentBoolRefinement.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 142, "start_col": 0, "start_line": 109 }
module DependentBoolRefinement module T = FStar.Tactics.V2 module R = FStar.Reflection.V2 open FStar.List.Tot module L = FStar.List.Tot #push-options "--z3cliopt 'smt.qi.eager_threshold=100' --z3cliopt 'smt.arith.nl=false'" let var = nat let index = nat let tun = R.pack_ln R.Tv_Unknown type src_exp = | EBVar : index -> src_exp | EVar : var -> src_exp | EBool : bool -> src_exp | EIf : src_exp -> src_exp -> src_exp -> src_exp | ELam : src_ty -> src_exp -> src_exp | EApp : src_exp -> src_exp -> src_exp and src_ty = | TBool : src_ty | TRefineBool : src_exp -> src_ty | TArrow : src_ty -> src_ty -> src_ty let rec freevars (e:src_exp) : FStar.Set.set var = match e with | EVar v -> Set.singleton v | EBool _ | EBVar _ -> Set.empty | EIf b e1 e2 -> Set.union (freevars b) (Set.union (freevars e1) (freevars e2)) | ELam t e -> Set.union (freevars_ty t) (freevars e) | EApp e1 e2 -> Set.union (freevars e1) (freevars e2) and freevars_ty (t:src_ty) : Set.set var = match t with | TBool -> Set.empty | TArrow t1 t2 -> freevars_ty t1 `Set.union` freevars_ty t2 | TRefineBool e -> freevars e let rec ln' (e:src_exp) (n:int) : bool = match e with | EBool _ | EVar _ -> true | EBVar m -> m <= n | EIf b e1 e2 -> ln' b n && ln' e1 n && ln' e2 n | ELam t e -> ln_ty' t n && ln' e (n + 1) | EApp e1 e2 -> ln' e1 n && ln' e2 n and ln_ty' (t:src_ty) (n:int) : bool = match t with | TBool -> true | TRefineBool e -> ln' e (n + 1) | TArrow t1 t2 -> ln_ty' t1 n && ln_ty' t2 (n + 1) //Pi types let ln e = ln' e (-1) let ln_ty t = ln_ty' t (-1) let rec open_exp' (e:src_exp) (v:src_exp) (n:index) : Tot src_exp (decreases e) = match e with | EBool _ -> e | EVar m -> EVar m | EBVar m -> if m = n then v else EBVar m | EIf b e1 e2 -> EIf (open_exp' b v n) (open_exp' e1 v n) (open_exp' e2 v n) | ELam t e -> ELam (open_ty' t v n) (open_exp' e v (n + 1)) | EApp e1 e2 -> EApp (open_exp' e1 v n) (open_exp' e2 v n) and open_ty' (t:src_ty) (v:src_exp) (n:index) : Tot src_ty (decreases t) = match t with | TBool -> TBool | TRefineBool e -> TRefineBool (open_exp' e v (n + 1)) | TArrow t1 t2 -> TArrow (open_ty' t1 v n) (open_ty' t2 v (n + 1)) let rec close_exp' (e:src_exp) (v:var) (n:nat) : Tot src_exp (decreases e) = match e with | EBool _ -> e | EVar m -> if m = v then EBVar n else EVar m | EBVar m -> EBVar m | EIf b e1 e2 -> EIf (close_exp' b v n) (close_exp' e1 v n) (close_exp' e2 v n) | ELam t e -> ELam (close_ty' t v n) (close_exp' e v (n + 1)) | EApp e1 e2 -> EApp (close_exp' e1 v n) (close_exp' e2 v n) and close_ty' (t:src_ty) (v:var) (n:index) : Tot src_ty (decreases t) = match t with | TBool -> TBool | TRefineBool e -> TRefineBool (close_exp' e v (n + 1)) | TArrow t1 t2 -> TArrow (close_ty' t1 v n) (close_ty' t2 v (n + 1)) let open_exp e v = open_exp' e (EVar v) 0 let close_exp e v = close_exp' e v 0 let open_with e e' = open_exp' e e' 0 let open_ty t v = open_ty' t (EVar v) 0 let close_ty t v = close_ty' t v 0 let open_ty_with t e = open_ty' t e 0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "DependentBoolRefinement.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 4, "initial_ifuel": 2, "max_fuel": 4, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=100", "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 8, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: DependentBoolRefinement.src_exp -> v: DependentBoolRefinement.src_exp -> n: Prims.nat -> FStar.Pervasives.Lemma (ensures FStar.Set.subset (DependentBoolRefinement.freevars e) (DependentBoolRefinement.freevars (DependentBoolRefinement.open_exp' e v n)) /\ FStar.Set.subset (DependentBoolRefinement.freevars (DependentBoolRefinement.open_exp' e v n) ) (FStar.Set.union (DependentBoolRefinement.freevars e) (DependentBoolRefinement.freevars v) )) (decreases e)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[ "open_exp_freevars", "open_ty_freevars" ]
[ "DependentBoolRefinement.src_exp", "Prims.nat", "Prims.bool", "DependentBoolRefinement.index", "DependentBoolRefinement.var", "DependentBoolRefinement.open_exp_freevars", "Prims.unit", "DependentBoolRefinement.src_ty", "Prims.op_Addition", "DependentBoolRefinement.open_ty_freevars", "Prims.l_True", "Prims.squash", "Prims.l_and", "FStar.Set.subset", "DependentBoolRefinement.freevars", "DependentBoolRefinement.open_exp'", "FStar.Set.union", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "mutual recursion" ]
false
false
true
false
false
let rec open_exp_freevars (e v: src_exp) (n: nat) : Lemma (ensures ((freevars e) `Set.subset` (freevars (open_exp' e v n))) /\ ((freevars (open_exp' e v n)) `Set.subset` ((freevars e) `Set.union` (freevars v)))) (decreases e) =
match e with | EBool _ | EBVar _ | EVar _ -> () | EApp e1 e2 -> open_exp_freevars e1 v n; open_exp_freevars e2 v n | EIf b e1 e2 -> open_exp_freevars b v n; open_exp_freevars e1 v n; open_exp_freevars e2 v n | ELam t e -> open_ty_freevars t v n; open_exp_freevars e v (n + 1)
false
Hacl.HMAC_DRBG.fst
Hacl.HMAC_DRBG.hash_len
val hash_len : a: Hacl.HMAC_DRBG.supported_alg -> n: Lib.IntTypes.size_t{Lib.IntTypes.v n = Spec.Hash.Definitions.hash_length a}
let hash_len (a:supported_alg) = Hacl.Hash.Definitions.hash_len a
{ "file_name": "code/drbg/Hacl.HMAC_DRBG.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 65, "end_line": 21, "start_col": 0, "start_line": 21 }
module Hacl.HMAC_DRBG open FStar.HyperStack.ST module ST = FStar.HyperStack.ST open Spec.Hash.Definitions open Lib.IntTypes open Lib.Buffer module HS = FStar.HyperStack module B = LowStar.Buffer module LSeq = Lib.Sequence module HMAC = Hacl.HMAC module S = Spec.HMAC_DRBG friend Spec.HMAC_DRBG
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fst.checked", "Spec.HMAC_DRBG.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.HMAC.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.HMAC_DRBG.fst" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
a: Hacl.HMAC_DRBG.supported_alg -> n: Lib.IntTypes.size_t{Lib.IntTypes.v n = Spec.Hash.Definitions.hash_length a}
Prims.Tot
[ "total" ]
[]
[ "Hacl.HMAC_DRBG.supported_alg", "Hacl.Hash.Definitions.hash_len", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Prims.l_and", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Spec.Hash.Definitions.hash_length" ]
[]
false
false
false
false
false
let hash_len (a: supported_alg) =
Hacl.Hash.Definitions.hash_len a
false
Hacl.HMAC_DRBG.fst
Hacl.HMAC_DRBG.freeable
val freeable: #a:supported_alg -> st:state a -> Type0
val freeable: #a:supported_alg -> st:state a -> Type0
let freeable #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.freeable k /\ B.freeable v /\ B.freeable ctr
{ "file_name": "code/drbg/Hacl.HMAC_DRBG.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 104, "start_col": 0, "start_line": 100 }
module Hacl.HMAC_DRBG open FStar.HyperStack.ST module ST = FStar.HyperStack.ST open Spec.Hash.Definitions open Lib.IntTypes open Lib.Buffer module HS = FStar.HyperStack module B = LowStar.Buffer module LSeq = Lib.Sequence module HMAC = Hacl.HMAC module S = Spec.HMAC_DRBG friend Spec.HMAC_DRBG unfold let hash_len (a:supported_alg) = Hacl.Hash.Definitions.hash_len a #set-options "--fuel 0 --ifuel 0 --z3rlimit 50" inline_for_extraction noextract val update_round: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> n:uint8 -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 k /\ live h0 v /\ live h0 data /\ disjoint k v /\ // HMAC input length must fit in size_t hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; as_seq h1 k == Spec.Agile.HMAC.hmac a (as_seq h0 k) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data))) /\ as_seq h1 v == Spec.Agile.HMAC.hmac a (as_seq h1 k) (as_seq h0 v) /\ modifies2 k v h0 h1) let update_round #a hmac len data n k v = let h0 = ST.get() in push_frame(); let input_len = hash_len a +! 1ul +! len in let input = create input_len (u8 0) in let k' = sub input 0ul (hash_len a) in copy k' v; if len <> 0ul then copy (sub input (hash_len a +! 1ul) len) data; input.(hash_len a) <- n; let h1 = ST.get() in assert (Seq.equal (as_seq h1 input) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data)))); S.hmac_input_bound a; hmac k' k (hash_len a) input input_len; hmac v k' (hash_len a) v (hash_len a); copy k k'; pop_frame() inline_for_extraction noextract val update: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 data /\ live h0 k /\ live h0 v /\ disjoint k v /\ disjoint k data /\ disjoint v data /\ hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; let k', v' = S.update #a (as_seq h0 data) (as_seq h0 k) (as_seq h0 v) in modifies2 k v h0 h1 /\ as_seq h1 k == k' /\ as_seq h1 v == v') let update #a hmac len data k v = update_round hmac len data (u8 0) k v; if len <> 0ul then update_round hmac len data (u8 1) k v noeq type state (a:supported_alg) = | State: k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> reseed_counter:lbuffer size_t 1ul {disjoint k v /\ disjoint k reseed_counter /\ disjoint v reseed_counter} -> state a
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fst.checked", "Spec.HMAC_DRBG.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.HMAC.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.HMAC_DRBG.fst" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
st: Hacl.HMAC_DRBG.state a -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.HMAC_DRBG.supported_alg", "Hacl.HMAC_DRBG.state", "Prims.l_and", "LowStar.Monotonic.Buffer.freeable", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "LowStar.Buffer.trivial_preorder", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "LowStar.Buffer.buffer", "Hacl.HMAC_DRBG.__proj__State__item__reseed_counter", "Hacl.HMAC_DRBG.__proj__State__item__v", "Hacl.HMAC_DRBG.__proj__State__item__k" ]
[]
false
false
false
false
true
let freeable #a st =
let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.freeable k /\ B.freeable v /\ B.freeable ctr
false
Hacl.HMAC_DRBG.fst
Hacl.HMAC_DRBG.instantiate
val instantiate: a:supported_alg -> instantiate_st a
val instantiate: a:supported_alg -> instantiate_st a
let instantiate a st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string = match a with | SHA1 -> mk_instantiate Hacl.HMAC.compute_sha1 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_256 -> mk_instantiate Hacl.HMAC.compute_sha2_256 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_384 -> mk_instantiate Hacl.HMAC.compute_sha2_384 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_512 -> mk_instantiate Hacl.HMAC.compute_sha2_512 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string
{ "file_name": "code/drbg/Hacl.HMAC_DRBG.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 217, "start_col": 0, "start_line": 192 }
module Hacl.HMAC_DRBG open FStar.HyperStack.ST module ST = FStar.HyperStack.ST open Spec.Hash.Definitions open Lib.IntTypes open Lib.Buffer module HS = FStar.HyperStack module B = LowStar.Buffer module LSeq = Lib.Sequence module HMAC = Hacl.HMAC module S = Spec.HMAC_DRBG friend Spec.HMAC_DRBG unfold let hash_len (a:supported_alg) = Hacl.Hash.Definitions.hash_len a #set-options "--fuel 0 --ifuel 0 --z3rlimit 50" inline_for_extraction noextract val update_round: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> n:uint8 -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 k /\ live h0 v /\ live h0 data /\ disjoint k v /\ // HMAC input length must fit in size_t hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; as_seq h1 k == Spec.Agile.HMAC.hmac a (as_seq h0 k) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data))) /\ as_seq h1 v == Spec.Agile.HMAC.hmac a (as_seq h1 k) (as_seq h0 v) /\ modifies2 k v h0 h1) let update_round #a hmac len data n k v = let h0 = ST.get() in push_frame(); let input_len = hash_len a +! 1ul +! len in let input = create input_len (u8 0) in let k' = sub input 0ul (hash_len a) in copy k' v; if len <> 0ul then copy (sub input (hash_len a +! 1ul) len) data; input.(hash_len a) <- n; let h1 = ST.get() in assert (Seq.equal (as_seq h1 input) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data)))); S.hmac_input_bound a; hmac k' k (hash_len a) input input_len; hmac v k' (hash_len a) v (hash_len a); copy k k'; pop_frame() inline_for_extraction noextract val update: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 data /\ live h0 k /\ live h0 v /\ disjoint k v /\ disjoint k data /\ disjoint v data /\ hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; let k', v' = S.update #a (as_seq h0 data) (as_seq h0 k) (as_seq h0 v) in modifies2 k v h0 h1 /\ as_seq h1 k == k' /\ as_seq h1 v == v') let update #a hmac len data k v = update_round hmac len data (u8 0) k v; if len <> 0ul then update_round hmac len data (u8 1) k v noeq type state (a:supported_alg) = | State: k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> reseed_counter:lbuffer size_t 1ul {disjoint k v /\ disjoint k reseed_counter /\ disjoint v reseed_counter} -> state a let freeable #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.freeable k /\ B.freeable v /\ B.freeable ctr let footprint #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.loc_addr_of_buffer k |+| B.loc_addr_of_buffer v |+| B.loc_addr_of_buffer ctr let invariant #a st h = live h st.k /\ live h st.v /\ live h st.reseed_counter /\ ( // JP: the disjoint predicate from lib hardcodes loc_buffer instead of // loc_addr_of_buffer, which prevents us from writing a proper free function // (probably why it wasn't written here in the first place)... we add on top // of the lib-style predicate a non-lib-style predicate which allows writing // an actual free function let k = st.k <: B.buffer uint8 in let v = st.v <: B.buffer uint8 in let ctr = st.reseed_counter <: B.buffer size_t in B.(all_disjoint [ loc_addr_of_buffer k; loc_addr_of_buffer v; loc_addr_of_buffer ctr ])) let repr #a st h = S.State (as_seq h st.k) (as_seq h st.v) (v (bget h st.reseed_counter 0)) let alloca a = let k = match a with | SHA1 -> create (hash_len SHA1) (u8 0) | SHA2_256 -> create (hash_len SHA2_256) (u8 0) | SHA2_384 -> create (hash_len SHA2_384) (u8 0) | SHA2_512 -> create (hash_len SHA2_512) (u8 0) in let v = match a with | SHA1 -> create (hash_len SHA1) (u8 0) | SHA2_256 -> create (hash_len SHA2_256) (u8 0) | SHA2_384 -> create (hash_len SHA2_384) (u8 0) | SHA2_512 -> create (hash_len SHA2_512) (u8 0) in let ctr = create 1ul 1ul in State k v ctr let create_in a r = let k:B.buffer uint8 = match a with | SHA1 -> B.malloc r (u8 0) (hash_len SHA1) | SHA2_256 -> B.malloc r (u8 0) (hash_len SHA2_256) | SHA2_384 -> B.malloc r (u8 0) (hash_len SHA2_384) | SHA2_512 -> B.malloc r (u8 0) (hash_len SHA2_512) in let v:B.buffer uint8 = match a with | SHA1 -> B.malloc r (u8 0) (hash_len SHA1) | SHA2_256 -> B.malloc r (u8 0) (hash_len SHA2_256) | SHA2_384 -> B.malloc r (u8 0) (hash_len SHA2_384) | SHA2_512 -> B.malloc r (u8 0) (hash_len SHA2_512) in let ctr:B.buffer size_t = B.malloc r 1ul 1ul in State k v ctr #push-options "--z3rlimit 200" let mk_instantiate #a hmac st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string = let h0 = ST.get () in push_frame(); let seed_material = create (entropy_input_len +! nonce_len +! personalization_string_len) (u8 0) in copy (sub seed_material 0ul entropy_input_len) entropy_input; copy (sub seed_material entropy_input_len nonce_len) nonce; copy (sub seed_material (entropy_input_len +! nonce_len) personalization_string_len) personalization_string; let State k v ctr = st in memset k (u8 0) (hash_len a); memset v (u8 1) (hash_len a); let h1 = ST.get () in assert (Seq.equal (as_seq h1 seed_material) (Seq.append (as_seq h0 entropy_input) (Seq.append (as_seq h0 nonce) (as_seq h0 personalization_string)))); assert (LSeq.equal (as_seq h1 k) (LSeq.create (hash_length a) (u8 0))); assert (LSeq.equal (as_seq h1 v) (LSeq.create (hash_length a) (u8 1))); ctr.(0ul) <- 1ul; update hmac (entropy_input_len +! nonce_len +! personalization_string_len) seed_material k v; pop_frame() #pop-options
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fst.checked", "Spec.HMAC_DRBG.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.HMAC.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.HMAC_DRBG.fst" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Hacl.HMAC_DRBG.supported_alg -> Hacl.HMAC_DRBG.instantiate_st a
Prims.Tot
[ "total" ]
[]
[ "Hacl.HMAC_DRBG.supported_alg", "Hacl.HMAC_DRBG.state", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.HMAC_DRBG.mk_instantiate", "Spec.Hash.Definitions.SHA1", "Hacl.HMAC.compute_sha1", "Prims.unit", "Spec.Hash.Definitions.SHA2_256", "Hacl.HMAC.compute_sha2_256", "Spec.Hash.Definitions.SHA2_384", "Hacl.HMAC.compute_sha2_384", "Spec.Hash.Definitions.SHA2_512", "Hacl.HMAC.compute_sha2_512" ]
[]
false
false
false
false
false
let instantiate a st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string =
match a with | SHA1 -> mk_instantiate Hacl.HMAC.compute_sha1 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_256 -> mk_instantiate Hacl.HMAC.compute_sha2_256 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_384 -> mk_instantiate Hacl.HMAC.compute_sha2_384 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_512 -> mk_instantiate Hacl.HMAC.compute_sha2_512 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string
false
Hacl.HMAC_DRBG.fst
Hacl.HMAC_DRBG.repr
val repr: #a:supported_alg -> st:state a -> h:HS.mem -> GTot (S.state a)
val repr: #a:supported_alg -> st:state a -> h:HS.mem -> GTot (S.state a)
let repr #a st h = S.State (as_seq h st.k) (as_seq h st.v) (v (bget h st.reseed_counter 0))
{ "file_name": "code/drbg/Hacl.HMAC_DRBG.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 74, "end_line": 125, "start_col": 0, "start_line": 124 }
module Hacl.HMAC_DRBG open FStar.HyperStack.ST module ST = FStar.HyperStack.ST open Spec.Hash.Definitions open Lib.IntTypes open Lib.Buffer module HS = FStar.HyperStack module B = LowStar.Buffer module LSeq = Lib.Sequence module HMAC = Hacl.HMAC module S = Spec.HMAC_DRBG friend Spec.HMAC_DRBG unfold let hash_len (a:supported_alg) = Hacl.Hash.Definitions.hash_len a #set-options "--fuel 0 --ifuel 0 --z3rlimit 50" inline_for_extraction noextract val update_round: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> n:uint8 -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 k /\ live h0 v /\ live h0 data /\ disjoint k v /\ // HMAC input length must fit in size_t hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; as_seq h1 k == Spec.Agile.HMAC.hmac a (as_seq h0 k) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data))) /\ as_seq h1 v == Spec.Agile.HMAC.hmac a (as_seq h1 k) (as_seq h0 v) /\ modifies2 k v h0 h1) let update_round #a hmac len data n k v = let h0 = ST.get() in push_frame(); let input_len = hash_len a +! 1ul +! len in let input = create input_len (u8 0) in let k' = sub input 0ul (hash_len a) in copy k' v; if len <> 0ul then copy (sub input (hash_len a +! 1ul) len) data; input.(hash_len a) <- n; let h1 = ST.get() in assert (Seq.equal (as_seq h1 input) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data)))); S.hmac_input_bound a; hmac k' k (hash_len a) input input_len; hmac v k' (hash_len a) v (hash_len a); copy k k'; pop_frame() inline_for_extraction noextract val update: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 data /\ live h0 k /\ live h0 v /\ disjoint k v /\ disjoint k data /\ disjoint v data /\ hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; let k', v' = S.update #a (as_seq h0 data) (as_seq h0 k) (as_seq h0 v) in modifies2 k v h0 h1 /\ as_seq h1 k == k' /\ as_seq h1 v == v') let update #a hmac len data k v = update_round hmac len data (u8 0) k v; if len <> 0ul then update_round hmac len data (u8 1) k v noeq type state (a:supported_alg) = | State: k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> reseed_counter:lbuffer size_t 1ul {disjoint k v /\ disjoint k reseed_counter /\ disjoint v reseed_counter} -> state a let freeable #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.freeable k /\ B.freeable v /\ B.freeable ctr let footprint #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.loc_addr_of_buffer k |+| B.loc_addr_of_buffer v |+| B.loc_addr_of_buffer ctr let invariant #a st h = live h st.k /\ live h st.v /\ live h st.reseed_counter /\ ( // JP: the disjoint predicate from lib hardcodes loc_buffer instead of // loc_addr_of_buffer, which prevents us from writing a proper free function // (probably why it wasn't written here in the first place)... we add on top // of the lib-style predicate a non-lib-style predicate which allows writing // an actual free function let k = st.k <: B.buffer uint8 in let v = st.v <: B.buffer uint8 in let ctr = st.reseed_counter <: B.buffer size_t in B.(all_disjoint [ loc_addr_of_buffer k; loc_addr_of_buffer v; loc_addr_of_buffer ctr ]))
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fst.checked", "Spec.HMAC_DRBG.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.HMAC.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.HMAC_DRBG.fst" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
st: Hacl.HMAC_DRBG.state a -> h: FStar.Monotonic.HyperStack.mem -> Prims.GTot (Spec.HMAC_DRBG.state a)
Prims.GTot
[ "sometrivial" ]
[]
[ "Hacl.HMAC_DRBG.supported_alg", "Hacl.HMAC_DRBG.state", "FStar.Monotonic.HyperStack.mem", "Spec.HMAC_DRBG.State", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint8", "Hacl.HMAC_DRBG.hash_len", "Hacl.HMAC_DRBG.__proj__State__item__k", "Hacl.HMAC_DRBG.__proj__State__item__v", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.bget", "Lib.IntTypes.size_t", "FStar.UInt32.__uint_to_t", "Hacl.HMAC_DRBG.__proj__State__item__reseed_counter", "Spec.HMAC_DRBG.state" ]
[]
false
false
false
false
false
let repr #a st h =
S.State (as_seq h st.k) (as_seq h st.v) (v (bget h st.reseed_counter 0))
false
Hacl.HMAC_DRBG.fst
Hacl.HMAC_DRBG.footprint
val footprint: #a:supported_alg -> st:state a -> GTot B.loc
val footprint: #a:supported_alg -> st:state a -> GTot B.loc
let footprint #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.loc_addr_of_buffer k |+| B.loc_addr_of_buffer v |+| B.loc_addr_of_buffer ctr
{ "file_name": "code/drbg/Hacl.HMAC_DRBG.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 80, "end_line": 110, "start_col": 0, "start_line": 106 }
module Hacl.HMAC_DRBG open FStar.HyperStack.ST module ST = FStar.HyperStack.ST open Spec.Hash.Definitions open Lib.IntTypes open Lib.Buffer module HS = FStar.HyperStack module B = LowStar.Buffer module LSeq = Lib.Sequence module HMAC = Hacl.HMAC module S = Spec.HMAC_DRBG friend Spec.HMAC_DRBG unfold let hash_len (a:supported_alg) = Hacl.Hash.Definitions.hash_len a #set-options "--fuel 0 --ifuel 0 --z3rlimit 50" inline_for_extraction noextract val update_round: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> n:uint8 -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 k /\ live h0 v /\ live h0 data /\ disjoint k v /\ // HMAC input length must fit in size_t hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; as_seq h1 k == Spec.Agile.HMAC.hmac a (as_seq h0 k) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data))) /\ as_seq h1 v == Spec.Agile.HMAC.hmac a (as_seq h1 k) (as_seq h0 v) /\ modifies2 k v h0 h1) let update_round #a hmac len data n k v = let h0 = ST.get() in push_frame(); let input_len = hash_len a +! 1ul +! len in let input = create input_len (u8 0) in let k' = sub input 0ul (hash_len a) in copy k' v; if len <> 0ul then copy (sub input (hash_len a +! 1ul) len) data; input.(hash_len a) <- n; let h1 = ST.get() in assert (Seq.equal (as_seq h1 input) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data)))); S.hmac_input_bound a; hmac k' k (hash_len a) input input_len; hmac v k' (hash_len a) v (hash_len a); copy k k'; pop_frame() inline_for_extraction noextract val update: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 data /\ live h0 k /\ live h0 v /\ disjoint k v /\ disjoint k data /\ disjoint v data /\ hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; let k', v' = S.update #a (as_seq h0 data) (as_seq h0 k) (as_seq h0 v) in modifies2 k v h0 h1 /\ as_seq h1 k == k' /\ as_seq h1 v == v') let update #a hmac len data k v = update_round hmac len data (u8 0) k v; if len <> 0ul then update_round hmac len data (u8 1) k v noeq type state (a:supported_alg) = | State: k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> reseed_counter:lbuffer size_t 1ul {disjoint k v /\ disjoint k reseed_counter /\ disjoint v reseed_counter} -> state a let freeable #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.freeable k /\ B.freeable v /\ B.freeable ctr
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fst.checked", "Spec.HMAC_DRBG.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.HMAC.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.HMAC_DRBG.fst" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
st: Hacl.HMAC_DRBG.state a -> Prims.GTot LowStar.Monotonic.Buffer.loc
Prims.GTot
[ "sometrivial" ]
[]
[ "Hacl.HMAC_DRBG.supported_alg", "Hacl.HMAC_DRBG.state", "Lib.Buffer.op_Bar_Plus_Bar", "LowStar.Monotonic.Buffer.loc_addr_of_buffer", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "LowStar.Buffer.trivial_preorder", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "LowStar.Buffer.buffer", "Hacl.HMAC_DRBG.__proj__State__item__reseed_counter", "Hacl.HMAC_DRBG.__proj__State__item__v", "Hacl.HMAC_DRBG.__proj__State__item__k", "LowStar.Monotonic.Buffer.loc" ]
[]
false
false
false
false
false
let footprint #a st =
let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.loc_addr_of_buffer k |+| B.loc_addr_of_buffer v |+| B.loc_addr_of_buffer ctr
false
Hacl.HMAC_DRBG.fst
Hacl.HMAC_DRBG.invariant
val invariant: #a:supported_alg -> st:state a -> h:HS.mem -> Type0
val invariant: #a:supported_alg -> st:state a -> h:HS.mem -> Type0
let invariant #a st h = live h st.k /\ live h st.v /\ live h st.reseed_counter /\ ( // JP: the disjoint predicate from lib hardcodes loc_buffer instead of // loc_addr_of_buffer, which prevents us from writing a proper free function // (probably why it wasn't written here in the first place)... we add on top // of the lib-style predicate a non-lib-style predicate which allows writing // an actual free function let k = st.k <: B.buffer uint8 in let v = st.v <: B.buffer uint8 in let ctr = st.reseed_counter <: B.buffer size_t in B.(all_disjoint [ loc_addr_of_buffer k; loc_addr_of_buffer v; loc_addr_of_buffer ctr ]))
{ "file_name": "code/drbg/Hacl.HMAC_DRBG.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 90, "end_line": 122, "start_col": 0, "start_line": 112 }
module Hacl.HMAC_DRBG open FStar.HyperStack.ST module ST = FStar.HyperStack.ST open Spec.Hash.Definitions open Lib.IntTypes open Lib.Buffer module HS = FStar.HyperStack module B = LowStar.Buffer module LSeq = Lib.Sequence module HMAC = Hacl.HMAC module S = Spec.HMAC_DRBG friend Spec.HMAC_DRBG unfold let hash_len (a:supported_alg) = Hacl.Hash.Definitions.hash_len a #set-options "--fuel 0 --ifuel 0 --z3rlimit 50" inline_for_extraction noextract val update_round: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> n:uint8 -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 k /\ live h0 v /\ live h0 data /\ disjoint k v /\ // HMAC input length must fit in size_t hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; as_seq h1 k == Spec.Agile.HMAC.hmac a (as_seq h0 k) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data))) /\ as_seq h1 v == Spec.Agile.HMAC.hmac a (as_seq h1 k) (as_seq h0 v) /\ modifies2 k v h0 h1) let update_round #a hmac len data n k v = let h0 = ST.get() in push_frame(); let input_len = hash_len a +! 1ul +! len in let input = create input_len (u8 0) in let k' = sub input 0ul (hash_len a) in copy k' v; if len <> 0ul then copy (sub input (hash_len a +! 1ul) len) data; input.(hash_len a) <- n; let h1 = ST.get() in assert (Seq.equal (as_seq h1 input) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data)))); S.hmac_input_bound a; hmac k' k (hash_len a) input input_len; hmac v k' (hash_len a) v (hash_len a); copy k k'; pop_frame() inline_for_extraction noextract val update: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 data /\ live h0 k /\ live h0 v /\ disjoint k v /\ disjoint k data /\ disjoint v data /\ hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; let k', v' = S.update #a (as_seq h0 data) (as_seq h0 k) (as_seq h0 v) in modifies2 k v h0 h1 /\ as_seq h1 k == k' /\ as_seq h1 v == v') let update #a hmac len data k v = update_round hmac len data (u8 0) k v; if len <> 0ul then update_round hmac len data (u8 1) k v noeq type state (a:supported_alg) = | State: k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> reseed_counter:lbuffer size_t 1ul {disjoint k v /\ disjoint k reseed_counter /\ disjoint v reseed_counter} -> state a let freeable #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.freeable k /\ B.freeable v /\ B.freeable ctr let footprint #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.loc_addr_of_buffer k |+| B.loc_addr_of_buffer v |+| B.loc_addr_of_buffer ctr
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fst.checked", "Spec.HMAC_DRBG.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.HMAC.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.HMAC_DRBG.fst" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
st: Hacl.HMAC_DRBG.state a -> h: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.HMAC_DRBG.supported_alg", "Hacl.HMAC_DRBG.state", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.IntTypes.uint8", "Hacl.HMAC_DRBG.__proj__State__item__k", "Hacl.HMAC_DRBG.__proj__State__item__v", "Lib.IntTypes.size_t", "Hacl.HMAC_DRBG.__proj__State__item__reseed_counter", "LowStar.Monotonic.Buffer.all_disjoint", "Prims.Cons", "LowStar.Monotonic.Buffer.loc", "LowStar.Monotonic.Buffer.loc_addr_of_buffer", "LowStar.Buffer.trivial_preorder", "Prims.Nil", "LowStar.Buffer.buffer", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.U8", "Lib.IntTypes.SEC" ]
[]
false
false
false
false
true
let invariant #a st h =
live h st.k /\ live h st.v /\ live h st.reseed_counter /\ (let k = st.k <: B.buffer uint8 in let v = st.v <: B.buffer uint8 in let ctr = st.reseed_counter <: B.buffer size_t in let open B in all_disjoint [loc_addr_of_buffer k; loc_addr_of_buffer v; loc_addr_of_buffer ctr])
false
CQueue.Cell.fst
CQueue.Cell.intro_ccell
val intro_ccell (#opened: _) (#a: Type0) (c: ccell_lvalue a) : SteelGhost unit opened (vptr (ccell_data c) `star` vptr (ccell_next c)) (fun _ -> ccell c) (fun _ -> True) (fun h res h' -> h' (ccell c) == ({ vcell_data = h (vptr (ccell_data c)); vcell_next = h (vptr (ccell_next c))}) )
val intro_ccell (#opened: _) (#a: Type0) (c: ccell_lvalue a) : SteelGhost unit opened (vptr (ccell_data c) `star` vptr (ccell_next c)) (fun _ -> ccell c) (fun _ -> True) (fun h res h' -> h' (ccell c) == ({ vcell_data = h (vptr (ccell_data c)); vcell_next = h (vptr (ccell_next c))}) )
let intro_ccell #opened #a c = intro_ccell_is_lvalue c; reveal_star (vptr (ccell_data c)) (vptr (ccell_next c)); intro_vdep (ccell_is_lvalue c) (vptr (ccell_data c) `star` vptr (ccell_next c)) (ccell0 a); intro_vrewrite (ccell_is_lvalue c `vdep` ccell0 a) (ccell_rewrite c); change_slprop_rel (ccell1 c) (ccell c) (fun x y -> x == y) (fun m -> assert_norm (hp_of (ccell1 c) == ccell_hp c); assert_norm (sel_of (ccell1 c) m === sel_of (ccell c) m) )
{ "file_name": "share/steel/examples/steel/CQueue.Cell.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 5, "end_line": 139, "start_col": 0, "start_line": 120 }
module CQueue.Cell (* A Steel model of C cell structs *) #push-options "--__no_positivity" noeq type mcell (a: Type0) = { data: ref a; next: ref (mcell a); all_or_none_null: squash (is_null data == is_null next); // TODO: /\ freeable data /\ freeable next, if freeable is implemented as a pure space proposition rather than as stateful permissions (i.e. "freeable if you have the whole permission") } #pop-options let ccell_ptrvalue a = mcell a let ccell_ptrvalue_null a = {data = null; next = null; all_or_none_null = ()} let ccell_ptrvalue_is_null #a x = is_null x.data let ccell_data #a c = c.data let ccell_next #a c = c.next let ccell_is_lvalue_refine (#a: Type) (c: ccell_ptrvalue a) (_: t_of emp) : Tot prop = ccell_ptrvalue_is_null c == false let ccell_is_lvalue_rewrite (#a: Type) (c: ccell_ptrvalue a) (_: normal (t_of (emp `vrefine` ccell_is_lvalue_refine c))) : GTot (ccell_lvalue a) = c [@@ __steel_reduce__; __reduce__ ] let ccell_is_lvalue0 (#a: Type) (c: ccell_ptrvalue a) : Tot vprop = emp `vrefine` ccell_is_lvalue_refine c `vrewrite` ccell_is_lvalue_rewrite c let ccell_is_lvalue_hp (#a: Type) (c: ccell_ptrvalue a) : Tot (slprop u#1) = hp_of (ccell_is_lvalue0 c) let ccell_is_lvalue_sel (#a: Type) (c: ccell_ptrvalue a) : GTot (selector (ccell_lvalue a) (ccell_is_lvalue_hp c)) = sel_of (ccell_is_lvalue0 c) let intro_ccell_is_lvalue #_ #a c = intro_vrefine emp (ccell_is_lvalue_refine c); intro_vrewrite (emp `vrefine` ccell_is_lvalue_refine c) (ccell_is_lvalue_rewrite c); change_slprop_rel (ccell_is_lvalue0 c) (ccell_is_lvalue c) (fun x y -> x == y) (fun m -> assert_norm (hp_of (ccell_is_lvalue c) == hp_of (ccell_is_lvalue0 c)); assert_norm (sel_of (ccell_is_lvalue c) m === sel_of (ccell_is_lvalue0 c) m) ) let elim_ccell_is_lvalue #_ #a c = change_slprop_rel (ccell_is_lvalue c) (ccell_is_lvalue0 c) (fun x y -> x == y) (fun m -> assert_norm (hp_of (ccell_is_lvalue c) == hp_of (ccell_is_lvalue0 c)); assert_norm (sel_of (ccell_is_lvalue c) m === sel_of (ccell_is_lvalue0 c) m) ); elim_vrewrite (emp `vrefine` ccell_is_lvalue_refine c) (ccell_is_lvalue_rewrite c); elim_vrefine emp (ccell_is_lvalue_refine c) [@@ __steel_reduce__] let ccell0 (a: Type0) (c: ccell_lvalue a) : Tot vprop = (vptr (ccell_data c) `star` vptr (ccell_next c)) // unfold let ccell_rewrite (#a: Type0) (c: ccell_ptrvalue a) (x: dtuple2 (ccell_lvalue a) (vdep_payload (ccell_is_lvalue c) (ccell0 a))) : GTot (vcell a) = let p = dsnd #(ccell_lvalue a) #(vdep_payload (ccell_is_lvalue c) (ccell0 a)) x in { vcell_data = fst p; vcell_next = snd p; } [@@ __steel_reduce__ ; __reduce__] // to avoid manual unfoldings through change_slprop let ccell1 (#a: Type0) (c: ccell_ptrvalue a) : Tot vprop = ccell_is_lvalue c `vdep` ccell0 a `vrewrite` ccell_rewrite c let ccell_hp #a c = hp_of (ccell1 c) let ccell_sel #a c = sel_of (ccell1 c)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "CQueue.Cell.fst" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "CQueue", "short_module": null }, { "abbrev": false, "full_module": "CQueue", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: CQueue.Cell.ccell_lvalue a -> Steel.Effect.Atomic.SteelGhost Prims.unit
Steel.Effect.Atomic.SteelGhost
[]
[]
[ "Steel.Memory.inames", "CQueue.Cell.ccell_lvalue", "Steel.Effect.Atomic.change_slprop_rel", "CQueue.Cell.ccell1", "CQueue.Cell.ccell", "Steel.Effect.Common.normal", "Steel.Effect.Common.t_of", "Prims.eq2", "Prims.prop", "Steel.Memory.mem", "FStar.Pervasives.assert_norm", "Prims.op_Equals_Equals_Equals", "Steel.Effect.Common.sel_of", "Prims.unit", "Steel.Memory.slprop", "Steel.Effect.Common.hp_of", "CQueue.Cell.ccell_hp", "Steel.Effect.Atomic.intro_vrewrite", "Steel.Effect.Common.vdep", "CQueue.Cell.ccell_is_lvalue", "CQueue.Cell.ccell0", "CQueue.Cell.vcell", "CQueue.Cell.ccell_rewrite", "Steel.Effect.Atomic.intro_vdep", "Steel.Effect.Common.star", "Steel.Reference.vptr", "CQueue.Cell.ccell_data", "CQueue.Cell.ccell_ptrvalue", "CQueue.Cell.ccell_next", "Steel.Effect.Atomic.reveal_star", "CQueue.Cell.intro_ccell_is_lvalue" ]
[]
false
true
false
false
false
let intro_ccell #opened #a c =
intro_ccell_is_lvalue c; reveal_star (vptr (ccell_data c)) (vptr (ccell_next c)); intro_vdep (ccell_is_lvalue c) ((vptr (ccell_data c)) `star` (vptr (ccell_next c))) (ccell0 a); intro_vrewrite ((ccell_is_lvalue c) `vdep` (ccell0 a)) (ccell_rewrite c); change_slprop_rel (ccell1 c) (ccell c) (fun x y -> x == y) (fun m -> assert_norm (hp_of (ccell1 c) == ccell_hp c); assert_norm (sel_of (ccell1 c) m === sel_of (ccell c) m))
false
Hacl.HMAC_DRBG.fst
Hacl.HMAC_DRBG.reseed
val reseed: a:supported_alg -> reseed_st a
val reseed: a:supported_alg -> reseed_st a
let reseed a st entropy_input_len entropy_input additional_input_input_len additional_input_input = match a with | SHA1 -> mk_reseed Hacl.HMAC.compute_sha1 st entropy_input_len entropy_input additional_input_input_len additional_input_input | SHA2_256 -> mk_reseed Hacl.HMAC.compute_sha2_256 st entropy_input_len entropy_input additional_input_input_len additional_input_input | SHA2_384 -> mk_reseed Hacl.HMAC.compute_sha2_384 st entropy_input_len entropy_input additional_input_input_len additional_input_input | SHA2_512 -> mk_reseed Hacl.HMAC.compute_sha2_512 st entropy_input_len entropy_input additional_input_input_len additional_input_input
{ "file_name": "code/drbg/Hacl.HMAC_DRBG.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 257, "start_col": 0, "start_line": 238 }
module Hacl.HMAC_DRBG open FStar.HyperStack.ST module ST = FStar.HyperStack.ST open Spec.Hash.Definitions open Lib.IntTypes open Lib.Buffer module HS = FStar.HyperStack module B = LowStar.Buffer module LSeq = Lib.Sequence module HMAC = Hacl.HMAC module S = Spec.HMAC_DRBG friend Spec.HMAC_DRBG unfold let hash_len (a:supported_alg) = Hacl.Hash.Definitions.hash_len a #set-options "--fuel 0 --ifuel 0 --z3rlimit 50" inline_for_extraction noextract val update_round: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> n:uint8 -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 k /\ live h0 v /\ live h0 data /\ disjoint k v /\ // HMAC input length must fit in size_t hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; as_seq h1 k == Spec.Agile.HMAC.hmac a (as_seq h0 k) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data))) /\ as_seq h1 v == Spec.Agile.HMAC.hmac a (as_seq h1 k) (as_seq h0 v) /\ modifies2 k v h0 h1) let update_round #a hmac len data n k v = let h0 = ST.get() in push_frame(); let input_len = hash_len a +! 1ul +! len in let input = create input_len (u8 0) in let k' = sub input 0ul (hash_len a) in copy k' v; if len <> 0ul then copy (sub input (hash_len a +! 1ul) len) data; input.(hash_len a) <- n; let h1 = ST.get() in assert (Seq.equal (as_seq h1 input) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data)))); S.hmac_input_bound a; hmac k' k (hash_len a) input input_len; hmac v k' (hash_len a) v (hash_len a); copy k k'; pop_frame() inline_for_extraction noextract val update: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 data /\ live h0 k /\ live h0 v /\ disjoint k v /\ disjoint k data /\ disjoint v data /\ hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; let k', v' = S.update #a (as_seq h0 data) (as_seq h0 k) (as_seq h0 v) in modifies2 k v h0 h1 /\ as_seq h1 k == k' /\ as_seq h1 v == v') let update #a hmac len data k v = update_round hmac len data (u8 0) k v; if len <> 0ul then update_round hmac len data (u8 1) k v noeq type state (a:supported_alg) = | State: k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> reseed_counter:lbuffer size_t 1ul {disjoint k v /\ disjoint k reseed_counter /\ disjoint v reseed_counter} -> state a let freeable #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.freeable k /\ B.freeable v /\ B.freeable ctr let footprint #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.loc_addr_of_buffer k |+| B.loc_addr_of_buffer v |+| B.loc_addr_of_buffer ctr let invariant #a st h = live h st.k /\ live h st.v /\ live h st.reseed_counter /\ ( // JP: the disjoint predicate from lib hardcodes loc_buffer instead of // loc_addr_of_buffer, which prevents us from writing a proper free function // (probably why it wasn't written here in the first place)... we add on top // of the lib-style predicate a non-lib-style predicate which allows writing // an actual free function let k = st.k <: B.buffer uint8 in let v = st.v <: B.buffer uint8 in let ctr = st.reseed_counter <: B.buffer size_t in B.(all_disjoint [ loc_addr_of_buffer k; loc_addr_of_buffer v; loc_addr_of_buffer ctr ])) let repr #a st h = S.State (as_seq h st.k) (as_seq h st.v) (v (bget h st.reseed_counter 0)) let alloca a = let k = match a with | SHA1 -> create (hash_len SHA1) (u8 0) | SHA2_256 -> create (hash_len SHA2_256) (u8 0) | SHA2_384 -> create (hash_len SHA2_384) (u8 0) | SHA2_512 -> create (hash_len SHA2_512) (u8 0) in let v = match a with | SHA1 -> create (hash_len SHA1) (u8 0) | SHA2_256 -> create (hash_len SHA2_256) (u8 0) | SHA2_384 -> create (hash_len SHA2_384) (u8 0) | SHA2_512 -> create (hash_len SHA2_512) (u8 0) in let ctr = create 1ul 1ul in State k v ctr let create_in a r = let k:B.buffer uint8 = match a with | SHA1 -> B.malloc r (u8 0) (hash_len SHA1) | SHA2_256 -> B.malloc r (u8 0) (hash_len SHA2_256) | SHA2_384 -> B.malloc r (u8 0) (hash_len SHA2_384) | SHA2_512 -> B.malloc r (u8 0) (hash_len SHA2_512) in let v:B.buffer uint8 = match a with | SHA1 -> B.malloc r (u8 0) (hash_len SHA1) | SHA2_256 -> B.malloc r (u8 0) (hash_len SHA2_256) | SHA2_384 -> B.malloc r (u8 0) (hash_len SHA2_384) | SHA2_512 -> B.malloc r (u8 0) (hash_len SHA2_512) in let ctr:B.buffer size_t = B.malloc r 1ul 1ul in State k v ctr #push-options "--z3rlimit 200" let mk_instantiate #a hmac st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string = let h0 = ST.get () in push_frame(); let seed_material = create (entropy_input_len +! nonce_len +! personalization_string_len) (u8 0) in copy (sub seed_material 0ul entropy_input_len) entropy_input; copy (sub seed_material entropy_input_len nonce_len) nonce; copy (sub seed_material (entropy_input_len +! nonce_len) personalization_string_len) personalization_string; let State k v ctr = st in memset k (u8 0) (hash_len a); memset v (u8 1) (hash_len a); let h1 = ST.get () in assert (Seq.equal (as_seq h1 seed_material) (Seq.append (as_seq h0 entropy_input) (Seq.append (as_seq h0 nonce) (as_seq h0 personalization_string)))); assert (LSeq.equal (as_seq h1 k) (LSeq.create (hash_length a) (u8 0))); assert (LSeq.equal (as_seq h1 v) (LSeq.create (hash_length a) (u8 1))); ctr.(0ul) <- 1ul; update hmac (entropy_input_len +! nonce_len +! personalization_string_len) seed_material k v; pop_frame() #pop-options let instantiate a st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string = match a with | SHA1 -> mk_instantiate Hacl.HMAC.compute_sha1 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_256 -> mk_instantiate Hacl.HMAC.compute_sha2_256 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_384 -> mk_instantiate Hacl.HMAC.compute_sha2_384 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_512 -> mk_instantiate Hacl.HMAC.compute_sha2_512 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string let mk_reseed #a hmac st entropy_input_len entropy_input additional_input_len additional_input = let h0 = ST.get () in push_frame(); let seed_material = create (entropy_input_len +! additional_input_len) (u8 0) in copy (sub seed_material 0ul entropy_input_len) entropy_input; copy (sub seed_material entropy_input_len additional_input_len) additional_input; let h1 = ST.get () in LSeq.eq_intro (as_seq h1 seed_material) LSeq.(as_seq h0 entropy_input @| as_seq h0 additional_input); let State k v ctr: state a = st in update hmac (entropy_input_len +! additional_input_len) seed_material k v; ctr.(0ul) <- 1ul; pop_frame()
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fst.checked", "Spec.HMAC_DRBG.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.HMAC.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.HMAC_DRBG.fst" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Hacl.HMAC_DRBG.supported_alg -> Hacl.HMAC_DRBG.reseed_st a
Prims.Tot
[ "total" ]
[]
[ "Hacl.HMAC_DRBG.supported_alg", "Hacl.HMAC_DRBG.state", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.HMAC_DRBG.mk_reseed", "Spec.Hash.Definitions.SHA1", "Hacl.HMAC.compute_sha1", "Prims.unit", "Spec.Hash.Definitions.SHA2_256", "Hacl.HMAC.compute_sha2_256", "Spec.Hash.Definitions.SHA2_384", "Hacl.HMAC.compute_sha2_384", "Spec.Hash.Definitions.SHA2_512", "Hacl.HMAC.compute_sha2_512" ]
[]
false
false
false
false
false
let reseed a st entropy_input_len entropy_input additional_input_input_len additional_input_input =
match a with | SHA1 -> mk_reseed Hacl.HMAC.compute_sha1 st entropy_input_len entropy_input additional_input_input_len additional_input_input | SHA2_256 -> mk_reseed Hacl.HMAC.compute_sha2_256 st entropy_input_len entropy_input additional_input_input_len additional_input_input | SHA2_384 -> mk_reseed Hacl.HMAC.compute_sha2_384 st entropy_input_len entropy_input additional_input_input_len additional_input_input | SHA2_512 -> mk_reseed Hacl.HMAC.compute_sha2_512 st entropy_input_len entropy_input additional_input_input_len additional_input_input
false
Hacl.HMAC_DRBG.fst
Hacl.HMAC_DRBG.generate
val generate: a:supported_alg -> generate_st a
val generate: a:supported_alg -> generate_st a
let generate a output st n additional_input_len additional_input = match a with | SHA1 -> mk_generate Hacl.HMAC.compute_sha1 output st n additional_input_len additional_input | SHA2_256 -> mk_generate Hacl.HMAC.compute_sha2_256 output st n additional_input_len additional_input | SHA2_384 -> mk_generate Hacl.HMAC.compute_sha2_384 output st n additional_input_len additional_input | SHA2_512 -> mk_generate Hacl.HMAC.compute_sha2_512 output st n additional_input_len additional_input
{ "file_name": "code/drbg/Hacl.HMAC_DRBG.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 43, "end_line": 319, "start_col": 0, "start_line": 306 }
module Hacl.HMAC_DRBG open FStar.HyperStack.ST module ST = FStar.HyperStack.ST open Spec.Hash.Definitions open Lib.IntTypes open Lib.Buffer module HS = FStar.HyperStack module B = LowStar.Buffer module LSeq = Lib.Sequence module HMAC = Hacl.HMAC module S = Spec.HMAC_DRBG friend Spec.HMAC_DRBG unfold let hash_len (a:supported_alg) = Hacl.Hash.Definitions.hash_len a #set-options "--fuel 0 --ifuel 0 --z3rlimit 50" inline_for_extraction noextract val update_round: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> n:uint8 -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 k /\ live h0 v /\ live h0 data /\ disjoint k v /\ // HMAC input length must fit in size_t hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; as_seq h1 k == Spec.Agile.HMAC.hmac a (as_seq h0 k) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data))) /\ as_seq h1 v == Spec.Agile.HMAC.hmac a (as_seq h1 k) (as_seq h0 v) /\ modifies2 k v h0 h1) let update_round #a hmac len data n k v = let h0 = ST.get() in push_frame(); let input_len = hash_len a +! 1ul +! len in let input = create input_len (u8 0) in let k' = sub input 0ul (hash_len a) in copy k' v; if len <> 0ul then copy (sub input (hash_len a +! 1ul) len) data; input.(hash_len a) <- n; let h1 = ST.get() in assert (Seq.equal (as_seq h1 input) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data)))); S.hmac_input_bound a; hmac k' k (hash_len a) input input_len; hmac v k' (hash_len a) v (hash_len a); copy k k'; pop_frame() inline_for_extraction noextract val update: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 data /\ live h0 k /\ live h0 v /\ disjoint k v /\ disjoint k data /\ disjoint v data /\ hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; let k', v' = S.update #a (as_seq h0 data) (as_seq h0 k) (as_seq h0 v) in modifies2 k v h0 h1 /\ as_seq h1 k == k' /\ as_seq h1 v == v') let update #a hmac len data k v = update_round hmac len data (u8 0) k v; if len <> 0ul then update_round hmac len data (u8 1) k v noeq type state (a:supported_alg) = | State: k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> reseed_counter:lbuffer size_t 1ul {disjoint k v /\ disjoint k reseed_counter /\ disjoint v reseed_counter} -> state a let freeable #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.freeable k /\ B.freeable v /\ B.freeable ctr let footprint #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.loc_addr_of_buffer k |+| B.loc_addr_of_buffer v |+| B.loc_addr_of_buffer ctr let invariant #a st h = live h st.k /\ live h st.v /\ live h st.reseed_counter /\ ( // JP: the disjoint predicate from lib hardcodes loc_buffer instead of // loc_addr_of_buffer, which prevents us from writing a proper free function // (probably why it wasn't written here in the first place)... we add on top // of the lib-style predicate a non-lib-style predicate which allows writing // an actual free function let k = st.k <: B.buffer uint8 in let v = st.v <: B.buffer uint8 in let ctr = st.reseed_counter <: B.buffer size_t in B.(all_disjoint [ loc_addr_of_buffer k; loc_addr_of_buffer v; loc_addr_of_buffer ctr ])) let repr #a st h = S.State (as_seq h st.k) (as_seq h st.v) (v (bget h st.reseed_counter 0)) let alloca a = let k = match a with | SHA1 -> create (hash_len SHA1) (u8 0) | SHA2_256 -> create (hash_len SHA2_256) (u8 0) | SHA2_384 -> create (hash_len SHA2_384) (u8 0) | SHA2_512 -> create (hash_len SHA2_512) (u8 0) in let v = match a with | SHA1 -> create (hash_len SHA1) (u8 0) | SHA2_256 -> create (hash_len SHA2_256) (u8 0) | SHA2_384 -> create (hash_len SHA2_384) (u8 0) | SHA2_512 -> create (hash_len SHA2_512) (u8 0) in let ctr = create 1ul 1ul in State k v ctr let create_in a r = let k:B.buffer uint8 = match a with | SHA1 -> B.malloc r (u8 0) (hash_len SHA1) | SHA2_256 -> B.malloc r (u8 0) (hash_len SHA2_256) | SHA2_384 -> B.malloc r (u8 0) (hash_len SHA2_384) | SHA2_512 -> B.malloc r (u8 0) (hash_len SHA2_512) in let v:B.buffer uint8 = match a with | SHA1 -> B.malloc r (u8 0) (hash_len SHA1) | SHA2_256 -> B.malloc r (u8 0) (hash_len SHA2_256) | SHA2_384 -> B.malloc r (u8 0) (hash_len SHA2_384) | SHA2_512 -> B.malloc r (u8 0) (hash_len SHA2_512) in let ctr:B.buffer size_t = B.malloc r 1ul 1ul in State k v ctr #push-options "--z3rlimit 200" let mk_instantiate #a hmac st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string = let h0 = ST.get () in push_frame(); let seed_material = create (entropy_input_len +! nonce_len +! personalization_string_len) (u8 0) in copy (sub seed_material 0ul entropy_input_len) entropy_input; copy (sub seed_material entropy_input_len nonce_len) nonce; copy (sub seed_material (entropy_input_len +! nonce_len) personalization_string_len) personalization_string; let State k v ctr = st in memset k (u8 0) (hash_len a); memset v (u8 1) (hash_len a); let h1 = ST.get () in assert (Seq.equal (as_seq h1 seed_material) (Seq.append (as_seq h0 entropy_input) (Seq.append (as_seq h0 nonce) (as_seq h0 personalization_string)))); assert (LSeq.equal (as_seq h1 k) (LSeq.create (hash_length a) (u8 0))); assert (LSeq.equal (as_seq h1 v) (LSeq.create (hash_length a) (u8 1))); ctr.(0ul) <- 1ul; update hmac (entropy_input_len +! nonce_len +! personalization_string_len) seed_material k v; pop_frame() #pop-options let instantiate a st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string = match a with | SHA1 -> mk_instantiate Hacl.HMAC.compute_sha1 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_256 -> mk_instantiate Hacl.HMAC.compute_sha2_256 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_384 -> mk_instantiate Hacl.HMAC.compute_sha2_384 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_512 -> mk_instantiate Hacl.HMAC.compute_sha2_512 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string let mk_reseed #a hmac st entropy_input_len entropy_input additional_input_len additional_input = let h0 = ST.get () in push_frame(); let seed_material = create (entropy_input_len +! additional_input_len) (u8 0) in copy (sub seed_material 0ul entropy_input_len) entropy_input; copy (sub seed_material entropy_input_len additional_input_len) additional_input; let h1 = ST.get () in LSeq.eq_intro (as_seq h1 seed_material) LSeq.(as_seq h0 entropy_input @| as_seq h0 additional_input); let State k v ctr: state a = st in update hmac (entropy_input_len +! additional_input_len) seed_material k v; ctr.(0ul) <- 1ul; pop_frame() let reseed a st entropy_input_len entropy_input additional_input_input_len additional_input_input = match a with | SHA1 -> mk_reseed Hacl.HMAC.compute_sha1 st entropy_input_len entropy_input additional_input_input_len additional_input_input | SHA2_256 -> mk_reseed Hacl.HMAC.compute_sha2_256 st entropy_input_len entropy_input additional_input_input_len additional_input_input | SHA2_384 -> mk_reseed Hacl.HMAC.compute_sha2_384 st entropy_input_len entropy_input additional_input_input_len additional_input_input | SHA2_512 -> mk_reseed Hacl.HMAC.compute_sha2_512 st entropy_input_len entropy_input additional_input_input_len additional_input_input #push-options "--z3rlimit 300" let mk_generate #a hmac output st n additional_input_len additional_input = if st.reseed_counter.(0ul) >. reseed_interval then false else begin S.hmac_input_bound a; Math.Lemmas.lemma_div_mod (v n) (hash_length a); let State k v ctr = st in if additional_input_len >. 0ul then update hmac additional_input_len additional_input k v; let output:lbuffer uint8 n = output in let max = n /. hash_len a in let out = sub output 0ul (max *! hash_len a) in [@inline_let] let a_spec = S.a_spec a in [@inline_let] let refl h i = as_seq h v in [@inline_let] let spec h0 = S.generate_loop a (as_seq h0 k) (uint_v max) in let h0 = ST.get () in fill_blocks h0 (hash_len a) max out a_spec refl (fun i -> loc v) spec (fun i -> LSeq.unfold_generate_blocks (hash_length a) (uint_v max) a_spec (spec h0) (as_seq h0 v) (uint_v i); hmac v k (hash_len a) v (hash_len a); copy (sub out (i *! hash_len a) (hash_len a)) v ); if max *! hash_len a <. n then begin let h1 = ST.get () in let block = sub output (max *! hash_len a) (n -! (max *! hash_len a)) in hmac v k (hash_len a) v (hash_len a); copy block (sub v 0ul (n -! (max *! hash_len a))); let h2 = ST.get () in LSeq.eq_intro (as_seq h2 output) (as_seq h1 out `LSeq.op_At_Bar` as_seq h2 block) end; update hmac additional_input_len additional_input k v; let old_ctr = ctr.(0ul) in ctr.(0ul) <- old_ctr +! 1ul; true end #pop-options
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fst.checked", "Spec.HMAC_DRBG.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.HMAC.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.HMAC_DRBG.fst" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Hacl.HMAC_DRBG.supported_alg -> Hacl.HMAC_DRBG.generate_st a
Prims.Tot
[ "total" ]
[]
[ "Hacl.HMAC_DRBG.supported_alg", "Lib.Buffer.buffer", "Lib.IntTypes.uint8", "Hacl.HMAC_DRBG.state", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Hacl.HMAC_DRBG.mk_generate", "Spec.Hash.Definitions.SHA1", "Hacl.HMAC.compute_sha1", "Prims.bool", "Spec.Hash.Definitions.SHA2_256", "Hacl.HMAC.compute_sha2_256", "Spec.Hash.Definitions.SHA2_384", "Hacl.HMAC.compute_sha2_384", "Spec.Hash.Definitions.SHA2_512", "Hacl.HMAC.compute_sha2_512" ]
[]
false
false
false
false
false
let generate a output st n additional_input_len additional_input =
match a with | SHA1 -> mk_generate Hacl.HMAC.compute_sha1 output st n additional_input_len additional_input | SHA2_256 -> mk_generate Hacl.HMAC.compute_sha2_256 output st n additional_input_len additional_input | SHA2_384 -> mk_generate Hacl.HMAC.compute_sha2_384 output st n additional_input_len additional_input | SHA2_512 -> mk_generate Hacl.HMAC.compute_sha2_512 output st n additional_input_len additional_input
false
Hacl.HMAC_DRBG.fst
Hacl.HMAC_DRBG.alloca
val alloca: a:supported_alg -> StackInline (state a) (requires fun _ -> True) (ensures fun h0 st h1 -> B.modifies B.loc_none h0 h1 /\ B.fresh_loc (footprint st) h0 h1 /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint st)) /\ invariant st h1)
val alloca: a:supported_alg -> StackInline (state a) (requires fun _ -> True) (ensures fun h0 st h1 -> B.modifies B.loc_none h0 h1 /\ B.fresh_loc (footprint st) h0 h1 /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint st)) /\ invariant st h1)
let alloca a = let k = match a with | SHA1 -> create (hash_len SHA1) (u8 0) | SHA2_256 -> create (hash_len SHA2_256) (u8 0) | SHA2_384 -> create (hash_len SHA2_384) (u8 0) | SHA2_512 -> create (hash_len SHA2_512) (u8 0) in let v = match a with | SHA1 -> create (hash_len SHA1) (u8 0) | SHA2_256 -> create (hash_len SHA2_256) (u8 0) | SHA2_384 -> create (hash_len SHA2_384) (u8 0) | SHA2_512 -> create (hash_len SHA2_512) (u8 0) in let ctr = create 1ul 1ul in State k v ctr
{ "file_name": "code/drbg/Hacl.HMAC_DRBG.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 143, "start_col": 0, "start_line": 127 }
module Hacl.HMAC_DRBG open FStar.HyperStack.ST module ST = FStar.HyperStack.ST open Spec.Hash.Definitions open Lib.IntTypes open Lib.Buffer module HS = FStar.HyperStack module B = LowStar.Buffer module LSeq = Lib.Sequence module HMAC = Hacl.HMAC module S = Spec.HMAC_DRBG friend Spec.HMAC_DRBG unfold let hash_len (a:supported_alg) = Hacl.Hash.Definitions.hash_len a #set-options "--fuel 0 --ifuel 0 --z3rlimit 50" inline_for_extraction noextract val update_round: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> n:uint8 -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 k /\ live h0 v /\ live h0 data /\ disjoint k v /\ // HMAC input length must fit in size_t hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; as_seq h1 k == Spec.Agile.HMAC.hmac a (as_seq h0 k) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data))) /\ as_seq h1 v == Spec.Agile.HMAC.hmac a (as_seq h1 k) (as_seq h0 v) /\ modifies2 k v h0 h1) let update_round #a hmac len data n k v = let h0 = ST.get() in push_frame(); let input_len = hash_len a +! 1ul +! len in let input = create input_len (u8 0) in let k' = sub input 0ul (hash_len a) in copy k' v; if len <> 0ul then copy (sub input (hash_len a +! 1ul) len) data; input.(hash_len a) <- n; let h1 = ST.get() in assert (Seq.equal (as_seq h1 input) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data)))); S.hmac_input_bound a; hmac k' k (hash_len a) input input_len; hmac v k' (hash_len a) v (hash_len a); copy k k'; pop_frame() inline_for_extraction noextract val update: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 data /\ live h0 k /\ live h0 v /\ disjoint k v /\ disjoint k data /\ disjoint v data /\ hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; let k', v' = S.update #a (as_seq h0 data) (as_seq h0 k) (as_seq h0 v) in modifies2 k v h0 h1 /\ as_seq h1 k == k' /\ as_seq h1 v == v') let update #a hmac len data k v = update_round hmac len data (u8 0) k v; if len <> 0ul then update_round hmac len data (u8 1) k v noeq type state (a:supported_alg) = | State: k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> reseed_counter:lbuffer size_t 1ul {disjoint k v /\ disjoint k reseed_counter /\ disjoint v reseed_counter} -> state a let freeable #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.freeable k /\ B.freeable v /\ B.freeable ctr let footprint #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.loc_addr_of_buffer k |+| B.loc_addr_of_buffer v |+| B.loc_addr_of_buffer ctr let invariant #a st h = live h st.k /\ live h st.v /\ live h st.reseed_counter /\ ( // JP: the disjoint predicate from lib hardcodes loc_buffer instead of // loc_addr_of_buffer, which prevents us from writing a proper free function // (probably why it wasn't written here in the first place)... we add on top // of the lib-style predicate a non-lib-style predicate which allows writing // an actual free function let k = st.k <: B.buffer uint8 in let v = st.v <: B.buffer uint8 in let ctr = st.reseed_counter <: B.buffer size_t in B.(all_disjoint [ loc_addr_of_buffer k; loc_addr_of_buffer v; loc_addr_of_buffer ctr ])) let repr #a st h = S.State (as_seq h st.k) (as_seq h st.v) (v (bget h st.reseed_counter 0))
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fst.checked", "Spec.HMAC_DRBG.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.HMAC.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.HMAC_DRBG.fst" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Hacl.HMAC_DRBG.supported_alg -> FStar.HyperStack.ST.StackInline (Hacl.HMAC_DRBG.state a)
FStar.HyperStack.ST.StackInline
[]
[]
[ "Hacl.HMAC_DRBG.supported_alg", "Hacl.HMAC_DRBG.State", "Hacl.HMAC_DRBG.state", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.size_t", "FStar.UInt32.__uint_to_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Hacl.Hash.Definitions.hash_len", "Lib.IntTypes.uint8", "Hacl.HMAC_DRBG.hash_len", "Spec.Hash.Definitions.SHA1", "Lib.IntTypes.u8", "Spec.Hash.Definitions.SHA2_256", "Spec.Hash.Definitions.SHA2_384", "Spec.Hash.Definitions.SHA2_512" ]
[]
false
true
false
false
false
let alloca a =
let k = match a with | SHA1 -> create (hash_len SHA1) (u8 0) | SHA2_256 -> create (hash_len SHA2_256) (u8 0) | SHA2_384 -> create (hash_len SHA2_384) (u8 0) | SHA2_512 -> create (hash_len SHA2_512) (u8 0) in let v = match a with | SHA1 -> create (hash_len SHA1) (u8 0) | SHA2_256 -> create (hash_len SHA2_256) (u8 0) | SHA2_384 -> create (hash_len SHA2_384) (u8 0) | SHA2_512 -> create (hash_len SHA2_512) (u8 0) in let ctr = create 1ul 1ul in State k v ctr
false
Hacl.HMAC_DRBG.fst
Hacl.HMAC_DRBG.update
val update: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 data /\ live h0 k /\ live h0 v /\ disjoint k v /\ disjoint k data /\ disjoint v data /\ hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; let k', v' = S.update #a (as_seq h0 data) (as_seq h0 k) (as_seq h0 v) in modifies2 k v h0 h1 /\ as_seq h1 k == k' /\ as_seq h1 v == v')
val update: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 data /\ live h0 k /\ live h0 v /\ disjoint k v /\ disjoint k data /\ disjoint v data /\ hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; let k', v' = S.update #a (as_seq h0 data) (as_seq h0 k) (as_seq h0 v) in modifies2 k v h0 h1 /\ as_seq h1 k == k' /\ as_seq h1 v == v')
let update #a hmac len data k v = update_round hmac len data (u8 0) k v; if len <> 0ul then update_round hmac len data (u8 1) k v
{ "file_name": "code/drbg/Hacl.HMAC_DRBG.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 41, "end_line": 88, "start_col": 0, "start_line": 85 }
module Hacl.HMAC_DRBG open FStar.HyperStack.ST module ST = FStar.HyperStack.ST open Spec.Hash.Definitions open Lib.IntTypes open Lib.Buffer module HS = FStar.HyperStack module B = LowStar.Buffer module LSeq = Lib.Sequence module HMAC = Hacl.HMAC module S = Spec.HMAC_DRBG friend Spec.HMAC_DRBG unfold let hash_len (a:supported_alg) = Hacl.Hash.Definitions.hash_len a #set-options "--fuel 0 --ifuel 0 --z3rlimit 50" inline_for_extraction noextract val update_round: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> n:uint8 -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 k /\ live h0 v /\ live h0 data /\ disjoint k v /\ // HMAC input length must fit in size_t hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; as_seq h1 k == Spec.Agile.HMAC.hmac a (as_seq h0 k) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data))) /\ as_seq h1 v == Spec.Agile.HMAC.hmac a (as_seq h1 k) (as_seq h0 v) /\ modifies2 k v h0 h1) let update_round #a hmac len data n k v = let h0 = ST.get() in push_frame(); let input_len = hash_len a +! 1ul +! len in let input = create input_len (u8 0) in let k' = sub input 0ul (hash_len a) in copy k' v; if len <> 0ul then copy (sub input (hash_len a +! 1ul) len) data; input.(hash_len a) <- n; let h1 = ST.get() in assert (Seq.equal (as_seq h1 input) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data)))); S.hmac_input_bound a; hmac k' k (hash_len a) input input_len; hmac v k' (hash_len a) v (hash_len a); copy k k'; pop_frame() inline_for_extraction noextract val update: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 data /\ live h0 k /\ live h0 v /\ disjoint k v /\ disjoint k data /\ disjoint v data /\ hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; let k', v' = S.update #a (as_seq h0 data) (as_seq h0 k) (as_seq h0 v) in modifies2 k v h0 h1 /\ as_seq h1 k == k' /\ as_seq h1 v == v')
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fst.checked", "Spec.HMAC_DRBG.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.HMAC.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.HMAC_DRBG.fst" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
hmac: Hacl.HMAC.compute_st a -> len: Lib.IntTypes.size_t -> data: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.HMAC_DRBG.hash_len a) -> v: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.HMAC_DRBG.hash_len a) -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.HMAC_DRBG.supported_alg", "Hacl.HMAC.compute_st", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.HMAC_DRBG.hash_len", "Prims.op_disEquality", "FStar.UInt32.t", "FStar.UInt32.__uint_to_t", "Hacl.HMAC_DRBG.update_round", "Lib.IntTypes.u8", "Prims.unit", "Prims.bool" ]
[]
false
true
false
false
false
let update #a hmac len data k v =
update_round hmac len data (u8 0) k v; if len <> 0ul then update_round hmac len data (u8 1) k v
false
Hacl.HMAC_DRBG.fst
Hacl.HMAC_DRBG.create_in
val create_in: a:supported_alg -> r:HS.rid -> ST (state a) (requires fun _ -> is_eternal_region r) (ensures fun h0 st h1 -> B.modifies B.loc_none h0 h1 /\ B.fresh_loc (footprint st) h0 h1 /\ B.(loc_includes (loc_region_only true r)) (footprint st) /\ invariant st h1 /\ freeable st)
val create_in: a:supported_alg -> r:HS.rid -> ST (state a) (requires fun _ -> is_eternal_region r) (ensures fun h0 st h1 -> B.modifies B.loc_none h0 h1 /\ B.fresh_loc (footprint st) h0 h1 /\ B.(loc_includes (loc_region_only true r)) (footprint st) /\ invariant st h1 /\ freeable st)
let create_in a r = let k:B.buffer uint8 = match a with | SHA1 -> B.malloc r (u8 0) (hash_len SHA1) | SHA2_256 -> B.malloc r (u8 0) (hash_len SHA2_256) | SHA2_384 -> B.malloc r (u8 0) (hash_len SHA2_384) | SHA2_512 -> B.malloc r (u8 0) (hash_len SHA2_512) in let v:B.buffer uint8 = match a with | SHA1 -> B.malloc r (u8 0) (hash_len SHA1) | SHA2_256 -> B.malloc r (u8 0) (hash_len SHA2_256) | SHA2_384 -> B.malloc r (u8 0) (hash_len SHA2_384) | SHA2_512 -> B.malloc r (u8 0) (hash_len SHA2_512) in let ctr:B.buffer size_t = B.malloc r 1ul 1ul in State k v ctr
{ "file_name": "code/drbg/Hacl.HMAC_DRBG.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 161, "start_col": 0, "start_line": 145 }
module Hacl.HMAC_DRBG open FStar.HyperStack.ST module ST = FStar.HyperStack.ST open Spec.Hash.Definitions open Lib.IntTypes open Lib.Buffer module HS = FStar.HyperStack module B = LowStar.Buffer module LSeq = Lib.Sequence module HMAC = Hacl.HMAC module S = Spec.HMAC_DRBG friend Spec.HMAC_DRBG unfold let hash_len (a:supported_alg) = Hacl.Hash.Definitions.hash_len a #set-options "--fuel 0 --ifuel 0 --z3rlimit 50" inline_for_extraction noextract val update_round: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> n:uint8 -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 k /\ live h0 v /\ live h0 data /\ disjoint k v /\ // HMAC input length must fit in size_t hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; as_seq h1 k == Spec.Agile.HMAC.hmac a (as_seq h0 k) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data))) /\ as_seq h1 v == Spec.Agile.HMAC.hmac a (as_seq h1 k) (as_seq h0 v) /\ modifies2 k v h0 h1) let update_round #a hmac len data n k v = let h0 = ST.get() in push_frame(); let input_len = hash_len a +! 1ul +! len in let input = create input_len (u8 0) in let k' = sub input 0ul (hash_len a) in copy k' v; if len <> 0ul then copy (sub input (hash_len a +! 1ul) len) data; input.(hash_len a) <- n; let h1 = ST.get() in assert (Seq.equal (as_seq h1 input) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data)))); S.hmac_input_bound a; hmac k' k (hash_len a) input input_len; hmac v k' (hash_len a) v (hash_len a); copy k k'; pop_frame() inline_for_extraction noextract val update: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 data /\ live h0 k /\ live h0 v /\ disjoint k v /\ disjoint k data /\ disjoint v data /\ hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; let k', v' = S.update #a (as_seq h0 data) (as_seq h0 k) (as_seq h0 v) in modifies2 k v h0 h1 /\ as_seq h1 k == k' /\ as_seq h1 v == v') let update #a hmac len data k v = update_round hmac len data (u8 0) k v; if len <> 0ul then update_round hmac len data (u8 1) k v noeq type state (a:supported_alg) = | State: k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> reseed_counter:lbuffer size_t 1ul {disjoint k v /\ disjoint k reseed_counter /\ disjoint v reseed_counter} -> state a let freeable #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.freeable k /\ B.freeable v /\ B.freeable ctr let footprint #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.loc_addr_of_buffer k |+| B.loc_addr_of_buffer v |+| B.loc_addr_of_buffer ctr let invariant #a st h = live h st.k /\ live h st.v /\ live h st.reseed_counter /\ ( // JP: the disjoint predicate from lib hardcodes loc_buffer instead of // loc_addr_of_buffer, which prevents us from writing a proper free function // (probably why it wasn't written here in the first place)... we add on top // of the lib-style predicate a non-lib-style predicate which allows writing // an actual free function let k = st.k <: B.buffer uint8 in let v = st.v <: B.buffer uint8 in let ctr = st.reseed_counter <: B.buffer size_t in B.(all_disjoint [ loc_addr_of_buffer k; loc_addr_of_buffer v; loc_addr_of_buffer ctr ])) let repr #a st h = S.State (as_seq h st.k) (as_seq h st.v) (v (bget h st.reseed_counter 0)) let alloca a = let k = match a with | SHA1 -> create (hash_len SHA1) (u8 0) | SHA2_256 -> create (hash_len SHA2_256) (u8 0) | SHA2_384 -> create (hash_len SHA2_384) (u8 0) | SHA2_512 -> create (hash_len SHA2_512) (u8 0) in let v = match a with | SHA1 -> create (hash_len SHA1) (u8 0) | SHA2_256 -> create (hash_len SHA2_256) (u8 0) | SHA2_384 -> create (hash_len SHA2_384) (u8 0) | SHA2_512 -> create (hash_len SHA2_512) (u8 0) in let ctr = create 1ul 1ul in State k v ctr
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fst.checked", "Spec.HMAC_DRBG.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.HMAC.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.HMAC_DRBG.fst" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Hacl.HMAC_DRBG.supported_alg -> r: FStar.Monotonic.HyperHeap.rid -> FStar.HyperStack.ST.ST (Hacl.HMAC_DRBG.state a)
FStar.HyperStack.ST.ST
[]
[]
[ "Hacl.HMAC_DRBG.supported_alg", "FStar.Monotonic.HyperHeap.rid", "Hacl.HMAC_DRBG.State", "Hacl.HMAC_DRBG.state", "LowStar.Buffer.buffer", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "LowStar.Buffer.malloc", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.UInt32.v", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.freeable", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.u8", "Hacl.HMAC_DRBG.hash_len", "Spec.Hash.Definitions.SHA1", "Spec.Hash.Definitions.SHA2_256", "Spec.Hash.Definitions.SHA2_384", "Spec.Hash.Definitions.SHA2_512" ]
[]
false
true
false
false
false
let create_in a r =
let k:B.buffer uint8 = match a with | SHA1 -> B.malloc r (u8 0) (hash_len SHA1) | SHA2_256 -> B.malloc r (u8 0) (hash_len SHA2_256) | SHA2_384 -> B.malloc r (u8 0) (hash_len SHA2_384) | SHA2_512 -> B.malloc r (u8 0) (hash_len SHA2_512) in let v:B.buffer uint8 = match a with | SHA1 -> B.malloc r (u8 0) (hash_len SHA1) | SHA2_256 -> B.malloc r (u8 0) (hash_len SHA2_256) | SHA2_384 -> B.malloc r (u8 0) (hash_len SHA2_384) | SHA2_512 -> B.malloc r (u8 0) (hash_len SHA2_512) in let ctr:B.buffer size_t = B.malloc r 1ul 1ul in State k v ctr
false
FStar.DM4F.IntStore.fst
FStar.DM4F.IntStore.in_
val in_ : x: FStar.DM4F.IntStore.id -> store: FStar.DM4F.IntStore.heap -> Prims.bool
let in_ (x:id) (store:heap) = x < length store
{ "file_name": "examples/dm4free/FStar.DM4F.IntStore.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 46, "end_line": 24, "start_col": 0, "start_line": 24 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.IntStore (* open FStar.DM4F.IntStoreAux *) open FStar.Seq type id = nat
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.IntStore.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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.DM4F.IntStore.id -> store: FStar.DM4F.IntStore.heap -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.IntStore.id", "FStar.DM4F.IntStore.heap", "Prims.op_LessThan", "FStar.Seq.Base.length", "Prims.int", "Prims.bool" ]
[]
false
false
false
true
false
let in_ (x: id) (store: heap) =
x < length store
false
DependentBoolRefinement.fst
DependentBoolRefinement.open_ty_freevars
val open_ty_freevars (t: src_ty) (v: src_exp) (n: nat) : Lemma (ensures ((freevars_ty t) `Set.subset` (freevars_ty (open_ty' t v n))) /\ ((freevars_ty (open_ty' t v n)) `Set.subset` ((freevars_ty t) `Set.union` (freevars v)))) (decreases t)
val open_ty_freevars (t: src_ty) (v: src_exp) (n: nat) : Lemma (ensures ((freevars_ty t) `Set.subset` (freevars_ty (open_ty' t v n))) /\ ((freevars_ty (open_ty' t v n)) `Set.subset` ((freevars_ty t) `Set.union` (freevars v)))) (decreases t)
let rec open_exp_freevars (e:src_exp) (v:src_exp) (n:nat) : Lemma (ensures (freevars e `Set.subset` freevars (open_exp' e v n)) /\ (freevars (open_exp' e v n) `Set.subset` (freevars e `Set.union` freevars v))) (decreases e) // [SMTPat (freevars (open_exp' e v n))] = match e with | EBool _ | EBVar _ | EVar _ -> () | EApp e1 e2 -> open_exp_freevars e1 v n; open_exp_freevars e2 v n | EIf b e1 e2 -> open_exp_freevars b v n; open_exp_freevars e1 v n; open_exp_freevars e2 v n | ELam t e -> open_ty_freevars t v n; open_exp_freevars e v (n + 1) and open_ty_freevars (t:src_ty) (v:src_exp) (n:nat) : Lemma (ensures (freevars_ty t `Set.subset` freevars_ty (open_ty' t v n)) /\ (freevars_ty (open_ty' t v n) `Set.subset` (freevars_ty t `Set.union` freevars v))) (decreases t) // [SMTPat (freevars_ty (open_ty' t v n))] = match t with | TBool -> () | TArrow t1 t2 -> open_ty_freevars t1 v n; open_ty_freevars t2 v (n + 1) | TRefineBool e -> open_exp_freevars e v (n + 1)
{ "file_name": "examples/dsls/dependent_bool_refinement/DependentBoolRefinement.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 142, "start_col": 0, "start_line": 109 }
module DependentBoolRefinement module T = FStar.Tactics.V2 module R = FStar.Reflection.V2 open FStar.List.Tot module L = FStar.List.Tot #push-options "--z3cliopt 'smt.qi.eager_threshold=100' --z3cliopt 'smt.arith.nl=false'" let var = nat let index = nat let tun = R.pack_ln R.Tv_Unknown type src_exp = | EBVar : index -> src_exp | EVar : var -> src_exp | EBool : bool -> src_exp | EIf : src_exp -> src_exp -> src_exp -> src_exp | ELam : src_ty -> src_exp -> src_exp | EApp : src_exp -> src_exp -> src_exp and src_ty = | TBool : src_ty | TRefineBool : src_exp -> src_ty | TArrow : src_ty -> src_ty -> src_ty let rec freevars (e:src_exp) : FStar.Set.set var = match e with | EVar v -> Set.singleton v | EBool _ | EBVar _ -> Set.empty | EIf b e1 e2 -> Set.union (freevars b) (Set.union (freevars e1) (freevars e2)) | ELam t e -> Set.union (freevars_ty t) (freevars e) | EApp e1 e2 -> Set.union (freevars e1) (freevars e2) and freevars_ty (t:src_ty) : Set.set var = match t with | TBool -> Set.empty | TArrow t1 t2 -> freevars_ty t1 `Set.union` freevars_ty t2 | TRefineBool e -> freevars e let rec ln' (e:src_exp) (n:int) : bool = match e with | EBool _ | EVar _ -> true | EBVar m -> m <= n | EIf b e1 e2 -> ln' b n && ln' e1 n && ln' e2 n | ELam t e -> ln_ty' t n && ln' e (n + 1) | EApp e1 e2 -> ln' e1 n && ln' e2 n and ln_ty' (t:src_ty) (n:int) : bool = match t with | TBool -> true | TRefineBool e -> ln' e (n + 1) | TArrow t1 t2 -> ln_ty' t1 n && ln_ty' t2 (n + 1) //Pi types let ln e = ln' e (-1) let ln_ty t = ln_ty' t (-1) let rec open_exp' (e:src_exp) (v:src_exp) (n:index) : Tot src_exp (decreases e) = match e with | EBool _ -> e | EVar m -> EVar m | EBVar m -> if m = n then v else EBVar m | EIf b e1 e2 -> EIf (open_exp' b v n) (open_exp' e1 v n) (open_exp' e2 v n) | ELam t e -> ELam (open_ty' t v n) (open_exp' e v (n + 1)) | EApp e1 e2 -> EApp (open_exp' e1 v n) (open_exp' e2 v n) and open_ty' (t:src_ty) (v:src_exp) (n:index) : Tot src_ty (decreases t) = match t with | TBool -> TBool | TRefineBool e -> TRefineBool (open_exp' e v (n + 1)) | TArrow t1 t2 -> TArrow (open_ty' t1 v n) (open_ty' t2 v (n + 1)) let rec close_exp' (e:src_exp) (v:var) (n:nat) : Tot src_exp (decreases e) = match e with | EBool _ -> e | EVar m -> if m = v then EBVar n else EVar m | EBVar m -> EBVar m | EIf b e1 e2 -> EIf (close_exp' b v n) (close_exp' e1 v n) (close_exp' e2 v n) | ELam t e -> ELam (close_ty' t v n) (close_exp' e v (n + 1)) | EApp e1 e2 -> EApp (close_exp' e1 v n) (close_exp' e2 v n) and close_ty' (t:src_ty) (v:var) (n:index) : Tot src_ty (decreases t) = match t with | TBool -> TBool | TRefineBool e -> TRefineBool (close_exp' e v (n + 1)) | TArrow t1 t2 -> TArrow (close_ty' t1 v n) (close_ty' t2 v (n + 1)) let open_exp e v = open_exp' e (EVar v) 0 let close_exp e v = close_exp' e v 0 let open_with e e' = open_exp' e e' 0 let open_ty t v = open_ty' t (EVar v) 0 let close_ty t v = close_ty' t v 0 let open_ty_with t e = open_ty' t e 0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "DependentBoolRefinement.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 4, "initial_ifuel": 2, "max_fuel": 4, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=100", "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 8, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: DependentBoolRefinement.src_ty -> v: DependentBoolRefinement.src_exp -> n: Prims.nat -> FStar.Pervasives.Lemma (ensures FStar.Set.subset (DependentBoolRefinement.freevars_ty t) (DependentBoolRefinement.freevars_ty (DependentBoolRefinement.open_ty' t v n)) /\ FStar.Set.subset (DependentBoolRefinement.freevars_ty (DependentBoolRefinement.open_ty' t v n)) (FStar.Set.union (DependentBoolRefinement.freevars_ty t) (DependentBoolRefinement.freevars v))) (decreases t)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[ "open_exp_freevars", "open_ty_freevars" ]
[ "DependentBoolRefinement.src_ty", "DependentBoolRefinement.src_exp", "Prims.nat", "DependentBoolRefinement.open_ty_freevars", "Prims.op_Addition", "Prims.unit", "DependentBoolRefinement.open_exp_freevars", "Prims.l_True", "Prims.squash", "Prims.l_and", "FStar.Set.subset", "DependentBoolRefinement.var", "DependentBoolRefinement.freevars_ty", "DependentBoolRefinement.open_ty'", "FStar.Set.union", "DependentBoolRefinement.freevars", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "mutual recursion" ]
false
false
true
false
false
let rec open_ty_freevars (t: src_ty) (v: src_exp) (n: nat) : Lemma (ensures ((freevars_ty t) `Set.subset` (freevars_ty (open_ty' t v n))) /\ ((freevars_ty (open_ty' t v n)) `Set.subset` ((freevars_ty t) `Set.union` (freevars v)))) (decreases t) =
match t with | TBool -> () | TArrow t1 t2 -> open_ty_freevars t1 v n; open_ty_freevars t2 v (n + 1) | TRefineBool e -> open_exp_freevars e v (n + 1)
false
Hacl.HMAC_DRBG.fst
Hacl.HMAC_DRBG.free
val free: #a:supported_alg -> free_st a
val free: #a:supported_alg -> free_st a
let free #_ s = let State k v ctr = s in B.free (k <: B.buffer uint8); B.free (v <: B.buffer uint8); B.free (ctr <: B.buffer size_t)
{ "file_name": "code/drbg/Hacl.HMAC_DRBG.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 325, "start_col": 0, "start_line": 321 }
module Hacl.HMAC_DRBG open FStar.HyperStack.ST module ST = FStar.HyperStack.ST open Spec.Hash.Definitions open Lib.IntTypes open Lib.Buffer module HS = FStar.HyperStack module B = LowStar.Buffer module LSeq = Lib.Sequence module HMAC = Hacl.HMAC module S = Spec.HMAC_DRBG friend Spec.HMAC_DRBG unfold let hash_len (a:supported_alg) = Hacl.Hash.Definitions.hash_len a #set-options "--fuel 0 --ifuel 0 --z3rlimit 50" inline_for_extraction noextract val update_round: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> n:uint8 -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 k /\ live h0 v /\ live h0 data /\ disjoint k v /\ // HMAC input length must fit in size_t hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; as_seq h1 k == Spec.Agile.HMAC.hmac a (as_seq h0 k) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data))) /\ as_seq h1 v == Spec.Agile.HMAC.hmac a (as_seq h1 k) (as_seq h0 v) /\ modifies2 k v h0 h1) let update_round #a hmac len data n k v = let h0 = ST.get() in push_frame(); let input_len = hash_len a +! 1ul +! len in let input = create input_len (u8 0) in let k' = sub input 0ul (hash_len a) in copy k' v; if len <> 0ul then copy (sub input (hash_len a +! 1ul) len) data; input.(hash_len a) <- n; let h1 = ST.get() in assert (Seq.equal (as_seq h1 input) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data)))); S.hmac_input_bound a; hmac k' k (hash_len a) input input_len; hmac v k' (hash_len a) v (hash_len a); copy k k'; pop_frame() inline_for_extraction noextract val update: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 data /\ live h0 k /\ live h0 v /\ disjoint k v /\ disjoint k data /\ disjoint v data /\ hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; let k', v' = S.update #a (as_seq h0 data) (as_seq h0 k) (as_seq h0 v) in modifies2 k v h0 h1 /\ as_seq h1 k == k' /\ as_seq h1 v == v') let update #a hmac len data k v = update_round hmac len data (u8 0) k v; if len <> 0ul then update_round hmac len data (u8 1) k v noeq type state (a:supported_alg) = | State: k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> reseed_counter:lbuffer size_t 1ul {disjoint k v /\ disjoint k reseed_counter /\ disjoint v reseed_counter} -> state a let freeable #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.freeable k /\ B.freeable v /\ B.freeable ctr let footprint #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.loc_addr_of_buffer k |+| B.loc_addr_of_buffer v |+| B.loc_addr_of_buffer ctr let invariant #a st h = live h st.k /\ live h st.v /\ live h st.reseed_counter /\ ( // JP: the disjoint predicate from lib hardcodes loc_buffer instead of // loc_addr_of_buffer, which prevents us from writing a proper free function // (probably why it wasn't written here in the first place)... we add on top // of the lib-style predicate a non-lib-style predicate which allows writing // an actual free function let k = st.k <: B.buffer uint8 in let v = st.v <: B.buffer uint8 in let ctr = st.reseed_counter <: B.buffer size_t in B.(all_disjoint [ loc_addr_of_buffer k; loc_addr_of_buffer v; loc_addr_of_buffer ctr ])) let repr #a st h = S.State (as_seq h st.k) (as_seq h st.v) (v (bget h st.reseed_counter 0)) let alloca a = let k = match a with | SHA1 -> create (hash_len SHA1) (u8 0) | SHA2_256 -> create (hash_len SHA2_256) (u8 0) | SHA2_384 -> create (hash_len SHA2_384) (u8 0) | SHA2_512 -> create (hash_len SHA2_512) (u8 0) in let v = match a with | SHA1 -> create (hash_len SHA1) (u8 0) | SHA2_256 -> create (hash_len SHA2_256) (u8 0) | SHA2_384 -> create (hash_len SHA2_384) (u8 0) | SHA2_512 -> create (hash_len SHA2_512) (u8 0) in let ctr = create 1ul 1ul in State k v ctr let create_in a r = let k:B.buffer uint8 = match a with | SHA1 -> B.malloc r (u8 0) (hash_len SHA1) | SHA2_256 -> B.malloc r (u8 0) (hash_len SHA2_256) | SHA2_384 -> B.malloc r (u8 0) (hash_len SHA2_384) | SHA2_512 -> B.malloc r (u8 0) (hash_len SHA2_512) in let v:B.buffer uint8 = match a with | SHA1 -> B.malloc r (u8 0) (hash_len SHA1) | SHA2_256 -> B.malloc r (u8 0) (hash_len SHA2_256) | SHA2_384 -> B.malloc r (u8 0) (hash_len SHA2_384) | SHA2_512 -> B.malloc r (u8 0) (hash_len SHA2_512) in let ctr:B.buffer size_t = B.malloc r 1ul 1ul in State k v ctr #push-options "--z3rlimit 200" let mk_instantiate #a hmac st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string = let h0 = ST.get () in push_frame(); let seed_material = create (entropy_input_len +! nonce_len +! personalization_string_len) (u8 0) in copy (sub seed_material 0ul entropy_input_len) entropy_input; copy (sub seed_material entropy_input_len nonce_len) nonce; copy (sub seed_material (entropy_input_len +! nonce_len) personalization_string_len) personalization_string; let State k v ctr = st in memset k (u8 0) (hash_len a); memset v (u8 1) (hash_len a); let h1 = ST.get () in assert (Seq.equal (as_seq h1 seed_material) (Seq.append (as_seq h0 entropy_input) (Seq.append (as_seq h0 nonce) (as_seq h0 personalization_string)))); assert (LSeq.equal (as_seq h1 k) (LSeq.create (hash_length a) (u8 0))); assert (LSeq.equal (as_seq h1 v) (LSeq.create (hash_length a) (u8 1))); ctr.(0ul) <- 1ul; update hmac (entropy_input_len +! nonce_len +! personalization_string_len) seed_material k v; pop_frame() #pop-options let instantiate a st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string = match a with | SHA1 -> mk_instantiate Hacl.HMAC.compute_sha1 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_256 -> mk_instantiate Hacl.HMAC.compute_sha2_256 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_384 -> mk_instantiate Hacl.HMAC.compute_sha2_384 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_512 -> mk_instantiate Hacl.HMAC.compute_sha2_512 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string let mk_reseed #a hmac st entropy_input_len entropy_input additional_input_len additional_input = let h0 = ST.get () in push_frame(); let seed_material = create (entropy_input_len +! additional_input_len) (u8 0) in copy (sub seed_material 0ul entropy_input_len) entropy_input; copy (sub seed_material entropy_input_len additional_input_len) additional_input; let h1 = ST.get () in LSeq.eq_intro (as_seq h1 seed_material) LSeq.(as_seq h0 entropy_input @| as_seq h0 additional_input); let State k v ctr: state a = st in update hmac (entropy_input_len +! additional_input_len) seed_material k v; ctr.(0ul) <- 1ul; pop_frame() let reseed a st entropy_input_len entropy_input additional_input_input_len additional_input_input = match a with | SHA1 -> mk_reseed Hacl.HMAC.compute_sha1 st entropy_input_len entropy_input additional_input_input_len additional_input_input | SHA2_256 -> mk_reseed Hacl.HMAC.compute_sha2_256 st entropy_input_len entropy_input additional_input_input_len additional_input_input | SHA2_384 -> mk_reseed Hacl.HMAC.compute_sha2_384 st entropy_input_len entropy_input additional_input_input_len additional_input_input | SHA2_512 -> mk_reseed Hacl.HMAC.compute_sha2_512 st entropy_input_len entropy_input additional_input_input_len additional_input_input #push-options "--z3rlimit 300" let mk_generate #a hmac output st n additional_input_len additional_input = if st.reseed_counter.(0ul) >. reseed_interval then false else begin S.hmac_input_bound a; Math.Lemmas.lemma_div_mod (v n) (hash_length a); let State k v ctr = st in if additional_input_len >. 0ul then update hmac additional_input_len additional_input k v; let output:lbuffer uint8 n = output in let max = n /. hash_len a in let out = sub output 0ul (max *! hash_len a) in [@inline_let] let a_spec = S.a_spec a in [@inline_let] let refl h i = as_seq h v in [@inline_let] let spec h0 = S.generate_loop a (as_seq h0 k) (uint_v max) in let h0 = ST.get () in fill_blocks h0 (hash_len a) max out a_spec refl (fun i -> loc v) spec (fun i -> LSeq.unfold_generate_blocks (hash_length a) (uint_v max) a_spec (spec h0) (as_seq h0 v) (uint_v i); hmac v k (hash_len a) v (hash_len a); copy (sub out (i *! hash_len a) (hash_len a)) v ); if max *! hash_len a <. n then begin let h1 = ST.get () in let block = sub output (max *! hash_len a) (n -! (max *! hash_len a)) in hmac v k (hash_len a) v (hash_len a); copy block (sub v 0ul (n -! (max *! hash_len a))); let h2 = ST.get () in LSeq.eq_intro (as_seq h2 output) (as_seq h1 out `LSeq.op_At_Bar` as_seq h2 block) end; update hmac additional_input_len additional_input k v; let old_ctr = ctr.(0ul) in ctr.(0ul) <- old_ctr +! 1ul; true end #pop-options let generate a output st n additional_input_len additional_input = match a with | SHA1 -> mk_generate Hacl.HMAC.compute_sha1 output st n additional_input_len additional_input | SHA2_256 -> mk_generate Hacl.HMAC.compute_sha2_256 output st n additional_input_len additional_input | SHA2_384 -> mk_generate Hacl.HMAC.compute_sha2_384 output st n additional_input_len additional_input | SHA2_512 -> mk_generate Hacl.HMAC.compute_sha2_512 output st n additional_input_len additional_input
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fst.checked", "Spec.HMAC_DRBG.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.HMAC.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.HMAC_DRBG.fst" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.HMAC_DRBG.free_st a
Prims.Tot
[ "total" ]
[]
[ "Hacl.HMAC_DRBG.supported_alg", "Hacl.HMAC_DRBG.state", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.HMAC_DRBG.hash_len", "Lib.IntTypes.size_t", "FStar.UInt32.__uint_to_t", "Prims.l_and", "Lib.Buffer.disjoint", "Lib.Buffer.MUT", "LowStar.Monotonic.Buffer.free", "LowStar.Buffer.trivial_preorder", "LowStar.Buffer.buffer", "Prims.unit" ]
[]
false
false
false
false
false
let free #_ s =
let State k v ctr = s in B.free (k <: B.buffer uint8); B.free (v <: B.buffer uint8); B.free (ctr <: B.buffer size_t)
false
FStar.DM4F.IntStore.fst
FStar.DM4F.IntStore.get
val get: Prims.unit -> int_store (heap)
val get: Prims.unit -> int_store (heap)
let get () : int_store (heap) = fun store -> Some store, store
{ "file_name": "examples/dm4free/FStar.DM4F.IntStore.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 62, "end_line": 36, "start_col": 0, "start_line": 36 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.IntStore (* open FStar.DM4F.IntStoreAux *) open FStar.Seq type id = nat type heap = seq int let in_ (x:id) (store:heap) = x < length store (* TODO : Try to use [either a exn] instead of [option] *) type int_store (a:Type) = heap -> M (option a * heap) let return_is (a:Type) (x:a) : int_store a = fun store -> Some x, store let bind_is (a b : Type) (x:int_store a) (f: a -> int_store b) : int_store b = fun store -> let (z, store') = x store in match z with | None -> None, store' | Some xa -> f xa store'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.IntStore.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.DM4F.IntStore.int_store FStar.DM4F.IntStore.heap
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.DM4F.IntStore.heap", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.DM4F.IntStore.int_store" ]
[]
false
false
false
true
false
let get () : int_store (heap) =
fun store -> Some store, store
false
FStar.DM4F.IntStore.fst
FStar.DM4F.IntStore.return_is
val return_is (a: Type) (x: a) : int_store a
val return_is (a: Type) (x: a) : int_store a
let return_is (a:Type) (x:a) : int_store a = fun store -> Some x, store
{ "file_name": "examples/dm4free/FStar.DM4F.IntStore.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 71, "end_line": 28, "start_col": 0, "start_line": 28 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.IntStore (* open FStar.DM4F.IntStoreAux *) open FStar.Seq type id = nat type heap = seq int let in_ (x:id) (store:heap) = x < length store (* TODO : Try to use [either a exn] instead of [option] *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.IntStore.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: Type -> x: a -> FStar.DM4F.IntStore.int_store a
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.IntStore.heap", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.DM4F.IntStore.int_store" ]
[]
false
false
false
true
false
let return_is (a: Type) (x: a) : int_store a =
fun store -> Some x, store
false
FStar.DM4F.IntStore.fst
FStar.DM4F.IntStore.raise_impl
val raise_impl: Prims.unit -> int_store False
val raise_impl: Prims.unit -> int_store False
let raise_impl () : int_store False = fun store -> None, store
{ "file_name": "examples/dm4free/FStar.DM4F.IntStore.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 62, "end_line": 41, "start_col": 0, "start_line": 41 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.IntStore (* open FStar.DM4F.IntStoreAux *) open FStar.Seq type id = nat type heap = seq int let in_ (x:id) (store:heap) = x < length store (* TODO : Try to use [either a exn] instead of [option] *) type int_store (a:Type) = heap -> M (option a * heap) let return_is (a:Type) (x:a) : int_store a = fun store -> Some x, store let bind_is (a b : Type) (x:int_store a) (f: a -> int_store b) : int_store b = fun store -> let (z, store') = x store in match z with | None -> None, store' | Some xa -> f xa store' let get () : int_store (heap) = fun store -> Some store, store let put s : int_store unit = fun _ -> Some (), s (* DM4F does not handle polymorphic types yet so we go around this limitation *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.IntStore.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.DM4F.IntStore.int_store Prims.l_False
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.DM4F.IntStore.heap", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.option", "Prims.l_False", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.tuple2", "FStar.DM4F.IntStore.int_store" ]
[]
false
false
false
true
false
let raise_impl () : int_store False =
fun store -> None, store
false
FStar.DM4F.IntStore.fst
FStar.DM4F.IntStore.bind_is
val bind_is (a b: Type) (x: int_store a) (f: (a -> int_store b)) : int_store b
val bind_is (a b: Type) (x: int_store a) (f: (a -> int_store b)) : int_store b
let bind_is (a b : Type) (x:int_store a) (f: a -> int_store b) : int_store b = fun store -> let (z, store') = x store in match z with | None -> None, store' | Some xa -> f xa store'
{ "file_name": "examples/dm4free/FStar.DM4F.IntStore.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 34, "start_col": 0, "start_line": 29 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.IntStore (* open FStar.DM4F.IntStoreAux *) open FStar.Seq type id = nat type heap = seq int let in_ (x:id) (store:heap) = x < length store (* TODO : Try to use [either a exn] instead of [option] *) type int_store (a:Type) = heap -> M (option a * heap)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.IntStore.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: Type -> b: Type -> x: FStar.DM4F.IntStore.int_store a -> f: (_: a -> FStar.DM4F.IntStore.int_store b) -> FStar.DM4F.IntStore.int_store b
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.IntStore.int_store", "FStar.DM4F.IntStore.heap", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.tuple2" ]
[]
false
false
false
true
false
let bind_is (a b: Type) (x: int_store a) (f: (a -> int_store b)) : int_store b =
fun store -> let z, store' = x store in match z with | None -> None, store' | Some xa -> f xa store'
false
CQueue.Cell.fst
CQueue.Cell.elim_ccell
val elim_ccell (#opened: _) (#a: Type0) (c: ccell_ptrvalue a) : SteelAtomic (ccell_lvalue a) opened (ccell c) (fun c' -> vptr (ccell_data c') `star` vptr (ccell_next c')) (fun _ -> True) (fun h c' h' -> ccell_ptrvalue_is_null c == false /\ (c' <: ccell_ptrvalue a) == c /\ h (ccell c) == { vcell_data = h' (vptr (ccell_data c')); vcell_next = h' (vptr (ccell_next c')) } )
val elim_ccell (#opened: _) (#a: Type0) (c: ccell_ptrvalue a) : SteelAtomic (ccell_lvalue a) opened (ccell c) (fun c' -> vptr (ccell_data c') `star` vptr (ccell_next c')) (fun _ -> True) (fun h c' h' -> ccell_ptrvalue_is_null c == false /\ (c' <: ccell_ptrvalue a) == c /\ h (ccell c) == { vcell_data = h' (vptr (ccell_data c')); vcell_next = h' (vptr (ccell_next c')) } )
let elim_ccell #opened #a c = let c2 = elim_ccell_ghost c in let c : ccell_lvalue a = c in change_equal_slprop (vptr (ccell_data c2)) (vptr (ccell_data c)); change_equal_slprop (vptr (ccell_next c2)) (vptr (ccell_next c)); return c
{ "file_name": "share/steel/examples/steel/CQueue.Cell.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 10, "end_line": 173, "start_col": 0, "start_line": 166 }
module CQueue.Cell (* A Steel model of C cell structs *) #push-options "--__no_positivity" noeq type mcell (a: Type0) = { data: ref a; next: ref (mcell a); all_or_none_null: squash (is_null data == is_null next); // TODO: /\ freeable data /\ freeable next, if freeable is implemented as a pure space proposition rather than as stateful permissions (i.e. "freeable if you have the whole permission") } #pop-options let ccell_ptrvalue a = mcell a let ccell_ptrvalue_null a = {data = null; next = null; all_or_none_null = ()} let ccell_ptrvalue_is_null #a x = is_null x.data let ccell_data #a c = c.data let ccell_next #a c = c.next let ccell_is_lvalue_refine (#a: Type) (c: ccell_ptrvalue a) (_: t_of emp) : Tot prop = ccell_ptrvalue_is_null c == false let ccell_is_lvalue_rewrite (#a: Type) (c: ccell_ptrvalue a) (_: normal (t_of (emp `vrefine` ccell_is_lvalue_refine c))) : GTot (ccell_lvalue a) = c [@@ __steel_reduce__; __reduce__ ] let ccell_is_lvalue0 (#a: Type) (c: ccell_ptrvalue a) : Tot vprop = emp `vrefine` ccell_is_lvalue_refine c `vrewrite` ccell_is_lvalue_rewrite c let ccell_is_lvalue_hp (#a: Type) (c: ccell_ptrvalue a) : Tot (slprop u#1) = hp_of (ccell_is_lvalue0 c) let ccell_is_lvalue_sel (#a: Type) (c: ccell_ptrvalue a) : GTot (selector (ccell_lvalue a) (ccell_is_lvalue_hp c)) = sel_of (ccell_is_lvalue0 c) let intro_ccell_is_lvalue #_ #a c = intro_vrefine emp (ccell_is_lvalue_refine c); intro_vrewrite (emp `vrefine` ccell_is_lvalue_refine c) (ccell_is_lvalue_rewrite c); change_slprop_rel (ccell_is_lvalue0 c) (ccell_is_lvalue c) (fun x y -> x == y) (fun m -> assert_norm (hp_of (ccell_is_lvalue c) == hp_of (ccell_is_lvalue0 c)); assert_norm (sel_of (ccell_is_lvalue c) m === sel_of (ccell_is_lvalue0 c) m) ) let elim_ccell_is_lvalue #_ #a c = change_slprop_rel (ccell_is_lvalue c) (ccell_is_lvalue0 c) (fun x y -> x == y) (fun m -> assert_norm (hp_of (ccell_is_lvalue c) == hp_of (ccell_is_lvalue0 c)); assert_norm (sel_of (ccell_is_lvalue c) m === sel_of (ccell_is_lvalue0 c) m) ); elim_vrewrite (emp `vrefine` ccell_is_lvalue_refine c) (ccell_is_lvalue_rewrite c); elim_vrefine emp (ccell_is_lvalue_refine c) [@@ __steel_reduce__] let ccell0 (a: Type0) (c: ccell_lvalue a) : Tot vprop = (vptr (ccell_data c) `star` vptr (ccell_next c)) // unfold let ccell_rewrite (#a: Type0) (c: ccell_ptrvalue a) (x: dtuple2 (ccell_lvalue a) (vdep_payload (ccell_is_lvalue c) (ccell0 a))) : GTot (vcell a) = let p = dsnd #(ccell_lvalue a) #(vdep_payload (ccell_is_lvalue c) (ccell0 a)) x in { vcell_data = fst p; vcell_next = snd p; } [@@ __steel_reduce__ ; __reduce__] // to avoid manual unfoldings through change_slprop let ccell1 (#a: Type0) (c: ccell_ptrvalue a) : Tot vprop = ccell_is_lvalue c `vdep` ccell0 a `vrewrite` ccell_rewrite c let ccell_hp #a c = hp_of (ccell1 c) let ccell_sel #a c = sel_of (ccell1 c) let intro_ccell #opened #a c = intro_ccell_is_lvalue c; reveal_star (vptr (ccell_data c)) (vptr (ccell_next c)); intro_vdep (ccell_is_lvalue c) (vptr (ccell_data c) `star` vptr (ccell_next c)) (ccell0 a); intro_vrewrite (ccell_is_lvalue c `vdep` ccell0 a) (ccell_rewrite c); change_slprop_rel (ccell1 c) (ccell c) (fun x y -> x == y) (fun m -> assert_norm (hp_of (ccell1 c) == ccell_hp c); assert_norm (sel_of (ccell1 c) m === sel_of (ccell c) m) ) let elim_ccell_ghost #opened #a c = change_slprop_rel (ccell c) (ccell1 c) (fun x y -> x == y) (fun m -> assert_norm (hp_of (ccell1 c) == ccell_hp c); assert_norm (sel_of (ccell1 c) m === sel_of (ccell c) m) ); elim_vrewrite (ccell_is_lvalue c `vdep` ccell0 a) (ccell_rewrite c); let c' : Ghost.erased (ccell_lvalue a) = elim_vdep (ccell_is_lvalue c) (ccell0 a) in elim_ccell_is_lvalue c; change_equal_slprop (ccell0 a c') (vptr (ccell_data (Ghost.reveal c')) `star` vptr (ccell_next (Ghost.reveal c'))); reveal_star (vptr (ccell_data (Ghost.reveal c'))) (vptr (ccell_next (Ghost.reveal c'))); c'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "CQueue.Cell.fst" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "CQueue", "short_module": null }, { "abbrev": false, "full_module": "CQueue", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: CQueue.Cell.ccell_ptrvalue a -> Steel.Effect.Atomic.SteelAtomic (CQueue.Cell.ccell_lvalue a)
Steel.Effect.Atomic.SteelAtomic
[]
[]
[ "Steel.Memory.inames", "CQueue.Cell.ccell_ptrvalue", "Steel.Effect.Atomic.return", "CQueue.Cell.ccell_lvalue", "Steel.Effect.Common.VStar", "Steel.Reference.vptrp", "CQueue.Cell.ccell_data", "Steel.FractionalPermission.full_perm", "CQueue.Cell.ccell_next", "Steel.Effect.Common.vprop", "Prims.unit", "Steel.Effect.Atomic.change_equal_slprop", "Steel.Reference.vptr", "FStar.Ghost.reveal", "FStar.Ghost.erased", "CQueue.Cell.elim_ccell_ghost" ]
[]
false
true
false
false
false
let elim_ccell #opened #a c =
let c2 = elim_ccell_ghost c in let c:ccell_lvalue a = c in change_equal_slprop (vptr (ccell_data c2)) (vptr (ccell_data c)); change_equal_slprop (vptr (ccell_next c2)) (vptr (ccell_next c)); return c
false
FStar.All.fst
FStar.All.all_pre
val all_pre : Type
let all_pre = all_pre_h heap
{ "file_name": "ulib/FStar.All.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 21, "start_col": 0, "start_line": 21 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.All open FStar.Heap include FStar.ST include FStar.Exn
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked", "FStar.Exn.fst.checked" ], "interface_file": false, "source_file": "FStar.All.fst" }
[ { "abbrev": false, "full_module": "FStar.Exn", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.all_pre_h", "FStar.Monotonic.Heap.heap" ]
[]
false
false
false
true
true
let all_pre =
all_pre_h heap
false
FStar.All.fst
FStar.All.lift_state_all
val lift_state_all : a: Type -> wp: FStar.ST.st_wp a -> p: FStar.All.all_post a -> FStar.Pervasives.st_pre_h FStar.Monotonic.Heap.heap
let lift_state_all (a : Type) (wp : st_wp a) (p : all_post a) = wp (fun a -> p (V a))
{ "file_name": "ulib/FStar.All.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 92, "end_line": 27, "start_col": 7, "start_line": 27 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.All open FStar.Heap include FStar.ST include FStar.Exn let all_pre = all_pre_h heap let all_post' (a : Type) (pre:Type) = all_post_h' heap a pre let all_post (a : Type) = all_post_h heap a let all_wp (a : Type) = all_wp_h heap a new_effect ALL = ALL_h heap
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked", "FStar.Exn.fst.checked" ], "interface_file": false, "source_file": "FStar.All.fst" }
[ { "abbrev": false, "full_module": "FStar.Exn", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> wp: FStar.ST.st_wp a -> p: FStar.All.all_post a -> FStar.Pervasives.st_pre_h FStar.Monotonic.Heap.heap
Prims.Tot
[ "total" ]
[]
[ "FStar.ST.st_wp", "FStar.All.all_post", "FStar.Pervasives.V", "FStar.Monotonic.Heap.heap", "Prims.l_True", "FStar.Pervasives.st_pre_h" ]
[]
false
false
false
true
false
let lift_state_all (a: Type) (wp: st_wp a) (p: all_post a) =
wp (fun a -> p (V a))
false
FStar.All.fst
FStar.All.all_post'
val all_post' : a: Type -> pre: Type -> Type
let all_post' (a : Type) (pre:Type) = all_post_h' heap a pre
{ "file_name": "ulib/FStar.All.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 60, "end_line": 22, "start_col": 0, "start_line": 22 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.All open FStar.Heap include FStar.ST include FStar.Exn
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked", "FStar.Exn.fst.checked" ], "interface_file": false, "source_file": "FStar.All.fst" }
[ { "abbrev": false, "full_module": "FStar.Exn", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> pre: Type -> Type
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.all_post_h'", "FStar.Monotonic.Heap.heap" ]
[]
false
false
false
true
true
let all_post' (a pre: Type) =
all_post_h' heap a pre
false
FStar.All.fst
FStar.All.all_post
val all_post : a: Type -> Type
let all_post (a : Type) = all_post_h heap a
{ "file_name": "ulib/FStar.All.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 23, "start_col": 0, "start_line": 23 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.All open FStar.Heap include FStar.ST include FStar.Exn let all_pre = all_pre_h heap
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked", "FStar.Exn.fst.checked" ], "interface_file": false, "source_file": "FStar.All.fst" }
[ { "abbrev": false, "full_module": "FStar.Exn", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> Type
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.all_post_h", "FStar.Monotonic.Heap.heap" ]
[]
false
false
false
true
true
let all_post (a: Type) =
all_post_h heap a
false
FStar.All.fst
FStar.All.all_wp
val all_wp : a: Type -> Type
let all_wp (a : Type) = all_wp_h heap a
{ "file_name": "ulib/FStar.All.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 24, "start_col": 0, "start_line": 24 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.All open FStar.Heap include FStar.ST include FStar.Exn let all_pre = all_pre_h heap let all_post' (a : Type) (pre:Type) = all_post_h' heap a pre
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked", "FStar.Exn.fst.checked" ], "interface_file": false, "source_file": "FStar.All.fst" }
[ { "abbrev": false, "full_module": "FStar.Exn", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> Type
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.all_wp_h", "FStar.Monotonic.Heap.heap" ]
[]
false
false
false
true
true
let all_wp (a: Type) =
all_wp_h heap a
false
FStar.All.fst
FStar.All.lift_exn_all
val lift_exn_all : a: Type -> wp: FStar.Pervasives.ex_wp a -> p: FStar.All.all_post a -> h: FStar.Monotonic.Heap.heap -> FStar.Pervasives.ex_pre
let lift_exn_all (a : Type) (wp : ex_wp a) (p : all_post a) (h : heap) = wp (fun ra -> p ra h)
{ "file_name": "ulib/FStar.All.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 94, "end_line": 31, "start_col": 0, "start_line": 31 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.All open FStar.Heap include FStar.ST include FStar.Exn let all_pre = all_pre_h heap let all_post' (a : Type) (pre:Type) = all_post_h' heap a pre let all_post (a : Type) = all_post_h heap a let all_wp (a : Type) = all_wp_h heap a new_effect ALL = ALL_h heap unfold let lift_state_all (a : Type) (wp : st_wp a) (p : all_post a) = wp (fun a -> p (V a)) sub_effect STATE ~> ALL { lift_wp = lift_state_all }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked", "FStar.Exn.fst.checked" ], "interface_file": false, "source_file": "FStar.All.fst" }
[ { "abbrev": false, "full_module": "FStar.Exn", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> wp: FStar.Pervasives.ex_wp a -> p: FStar.All.all_post a -> h: FStar.Monotonic.Heap.heap -> FStar.Pervasives.ex_pre
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.ex_wp", "FStar.All.all_post", "FStar.Monotonic.Heap.heap", "FStar.Pervasives.result", "Prims.l_True", "FStar.Pervasives.ex_pre" ]
[]
false
false
false
true
false
let lift_exn_all (a: Type) (wp: ex_wp a) (p: all_post a) (h: heap) =
wp (fun ra -> p ra h)
false
LListReverse.fst
LListReverse.push
val push (#l': Ghost.erased (list U64.t)) (#x: Ghost.erased llist_cell) (p p': ref llist_cell) : STT unit ((llist l' p') `star` (pts_to p full_perm x)) (fun p' -> llist (x.value :: l') p)
val push (#l': Ghost.erased (list U64.t)) (#x: Ghost.erased llist_cell) (p p': ref llist_cell) : STT unit ((llist l' p') `star` (pts_to p full_perm x)) (fun p' -> llist (x.value :: l') p)
let push (#l': Ghost.erased (list U64.t)) (#x: Ghost.erased llist_cell) (p: ref llist_cell) (p': ref llist_cell) : STT unit (llist l' p' `star` pts_to p full_perm x) (fun p' -> llist (x.value :: l') p) = // write p ({ read p with next = p' }); // weird Steel error let x_ = read p in write p ({ x_ with next = p' }); let x' = vpattern_replace (pts_to p full_perm) in vpattern_rewrite (llist _) x'.next; rewrite (llist_cons x.value (llist l') p) (llist (x.value :: l') p)
{ "file_name": "share/steel/tests/krml/LListReverse.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 69, "end_line": 92, "start_col": 0, "start_line": 78 }
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) 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 let pop (#l: Ghost.erased (list U64.t)) (p: ref llist_cell { Cons? l }) : STT (ref llist_cell) (llist l p) (fun p' -> exists_ (fun x -> pts_to p full_perm x `star` llist (List.Tot.tl l) p' `star` pure (x.value == List.Tot.hd l))) = rewrite (llist l p) (llist_cons (List.Tot.hd l) (llist (List.Tot.tl l)) p); let _ = gen_elim () in // let p' = (read p).next in // FIXME: "Effects STBase and Tot cannot be composed" let x = read p in let p' = x.next in vpattern_rewrite (llist _) p'; return p'
{ "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
p: Steel.ST.Reference.ref LListReverse.llist_cell -> p': Steel.ST.Reference.ref LListReverse.llist_cell -> Steel.ST.Effect.STT Prims.unit
Steel.ST.Effect.STT
[]
[]
[ "FStar.Ghost.erased", "Prims.list", "FStar.UInt64.t", "LListReverse.llist_cell", "Steel.ST.Reference.ref", "Steel.ST.Util.rewrite", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "LListReverse.llist_cons", "LListReverse.__proj__Mkllist_cell__item__value", "FStar.Ghost.reveal", "LListReverse.llist", "Prims.Cons", "Prims.unit", "Steel.ST.Util.vpattern_rewrite", "LListReverse.__proj__Mkllist_cell__item__next", "Steel.ST.Util.vpattern_replace", "LListReverse.Mkllist_cell", "Steel.ST.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Steel.ST.Reference.write", "Steel.ST.Reference.read", "Steel.Effect.Common.star", "Steel.Effect.Common.vprop" ]
[]
false
true
false
false
false
let push (#l': Ghost.erased (list U64.t)) (#x: Ghost.erased llist_cell) (p p': ref llist_cell) : STT unit ((llist l' p') `star` (pts_to p full_perm x)) (fun p' -> llist (x.value :: l') p) =
let x_ = read p in write p ({ x_ with next = p' }); let x' = vpattern_replace (pts_to p full_perm) in vpattern_rewrite (llist _) x'.next; rewrite (llist_cons x.value (llist l') p) (llist (x.value :: l') p)
false
Vale.X64.StateLemmas.fsti
Vale.X64.StateLemmas.machine_state
val machine_state : Type
let machine_state = Ms.machine_state
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 43, "end_line": 17, "start_col": 7, "start_line": 17 }
module Vale.X64.StateLemmas open Vale.X64.Machine_s open Vale.Arch.Heap open Vale.X64.State open FStar.FunctionalExtensionality module Ms = Vale.X64.Machine_Semantics_s //open Vale.X64.Machine_Semantics_s //module ME = Vale.X64.Memory open Vale.X64.Memory open Vale.Arch.MachineHeap_s //module MS = Vale.X64.Memory_Sems module VSS = Vale.X64.Stack_Sems module F = FStar.FunctionalExtensionality open Vale.Def.Prop_s open FStar.Mul
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Regs.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.StateLemmas.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "Ms" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Machine_Semantics_s.machine_state" ]
[]
false
false
false
true
true
let machine_state =
Ms.machine_state
false
Hacl.HMAC_DRBG.fst
Hacl.HMAC_DRBG.update_round
val update_round: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> n:uint8 -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 k /\ live h0 v /\ live h0 data /\ disjoint k v /\ // HMAC input length must fit in size_t hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; as_seq h1 k == Spec.Agile.HMAC.hmac a (as_seq h0 k) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data))) /\ as_seq h1 v == Spec.Agile.HMAC.hmac a (as_seq h1 k) (as_seq h0 v) /\ modifies2 k v h0 h1)
val update_round: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> n:uint8 -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 k /\ live h0 v /\ live h0 data /\ disjoint k v /\ // HMAC input length must fit in size_t hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; as_seq h1 k == Spec.Agile.HMAC.hmac a (as_seq h0 k) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data))) /\ as_seq h1 v == Spec.Agile.HMAC.hmac a (as_seq h1 k) (as_seq h0 v) /\ modifies2 k v h0 h1)
let update_round #a hmac len data n k v = let h0 = ST.get() in push_frame(); let input_len = hash_len a +! 1ul +! len in let input = create input_len (u8 0) in let k' = sub input 0ul (hash_len a) in copy k' v; if len <> 0ul then copy (sub input (hash_len a +! 1ul) len) data; input.(hash_len a) <- n; let h1 = ST.get() in assert (Seq.equal (as_seq h1 input) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data)))); S.hmac_input_bound a; hmac k' k (hash_len a) input input_len; hmac v k' (hash_len a) v (hash_len a); copy k k'; pop_frame()
{ "file_name": "code/drbg/Hacl.HMAC_DRBG.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 63, "start_col": 0, "start_line": 47 }
module Hacl.HMAC_DRBG open FStar.HyperStack.ST module ST = FStar.HyperStack.ST open Spec.Hash.Definitions open Lib.IntTypes open Lib.Buffer module HS = FStar.HyperStack module B = LowStar.Buffer module LSeq = Lib.Sequence module HMAC = Hacl.HMAC module S = Spec.HMAC_DRBG friend Spec.HMAC_DRBG unfold let hash_len (a:supported_alg) = Hacl.Hash.Definitions.hash_len a #set-options "--fuel 0 --ifuel 0 --z3rlimit 50" inline_for_extraction noextract val update_round: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> n:uint8 -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 k /\ live h0 v /\ live h0 data /\ disjoint k v /\ // HMAC input length must fit in size_t hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; as_seq h1 k == Spec.Agile.HMAC.hmac a (as_seq h0 k) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data))) /\ as_seq h1 v == Spec.Agile.HMAC.hmac a (as_seq h1 k) (as_seq h0 v) /\ modifies2 k v h0 h1)
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fst.checked", "Spec.HMAC_DRBG.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.HMAC.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.HMAC_DRBG.fst" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
hmac: Hacl.HMAC.compute_st a -> len: Lib.IntTypes.size_t -> data: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> n: Lib.IntTypes.uint8 -> k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.HMAC_DRBG.hash_len a) -> v: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.HMAC_DRBG.hash_len a) -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.HMAC_DRBG.supported_alg", "Hacl.HMAC.compute_st", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.HMAC_DRBG.hash_len", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Lib.Buffer.copy", "Lib.Buffer.MUT", "Spec.HMAC_DRBG.hmac_input_bound", "Prims._assert", "FStar.Seq.Base.equal", "Lib.Buffer.as_seq", "FStar.Seq.Base.append", "FStar.Seq.Base.cons", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.op_Array_Assignment", "Prims.op_disEquality", "FStar.UInt32.t", "FStar.UInt32.__uint_to_t", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.sub", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.bool", "Hacl.Hash.Definitions.hash_len", "Lib.Buffer.create", "Lib.IntTypes.u8", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let update_round #a hmac len data n k v =
let h0 = ST.get () in push_frame (); let input_len = hash_len a +! 1ul +! len in let input = create input_len (u8 0) in let k' = sub input 0ul (hash_len a) in copy k' v; if len <> 0ul then copy (sub input (hash_len a +! 1ul) len) data; input.(hash_len a) <- n; let h1 = ST.get () in assert (Seq.equal (as_seq h1 input) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data)))); S.hmac_input_bound a; hmac k' k (hash_len a) input input_len; hmac v k' (hash_len a) v (hash_len a); copy k k'; pop_frame ()
false
Hacl.HMAC_DRBG.fst
Hacl.HMAC_DRBG.mk_reseed
val mk_reseed: #a:supported_alg -> hmac:HMAC.compute_st a -> reseed_st a
val mk_reseed: #a:supported_alg -> hmac:HMAC.compute_st a -> reseed_st a
let mk_reseed #a hmac st entropy_input_len entropy_input additional_input_len additional_input = let h0 = ST.get () in push_frame(); let seed_material = create (entropy_input_len +! additional_input_len) (u8 0) in copy (sub seed_material 0ul entropy_input_len) entropy_input; copy (sub seed_material entropy_input_len additional_input_len) additional_input; let h1 = ST.get () in LSeq.eq_intro (as_seq h1 seed_material) LSeq.(as_seq h0 entropy_input @| as_seq h0 additional_input); let State k v ctr: state a = st in update hmac (entropy_input_len +! additional_input_len) seed_material k v; ctr.(0ul) <- 1ul; pop_frame()
{ "file_name": "code/drbg/Hacl.HMAC_DRBG.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 235, "start_col": 0, "start_line": 220 }
module Hacl.HMAC_DRBG open FStar.HyperStack.ST module ST = FStar.HyperStack.ST open Spec.Hash.Definitions open Lib.IntTypes open Lib.Buffer module HS = FStar.HyperStack module B = LowStar.Buffer module LSeq = Lib.Sequence module HMAC = Hacl.HMAC module S = Spec.HMAC_DRBG friend Spec.HMAC_DRBG unfold let hash_len (a:supported_alg) = Hacl.Hash.Definitions.hash_len a #set-options "--fuel 0 --ifuel 0 --z3rlimit 50" inline_for_extraction noextract val update_round: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> n:uint8 -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 k /\ live h0 v /\ live h0 data /\ disjoint k v /\ // HMAC input length must fit in size_t hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; as_seq h1 k == Spec.Agile.HMAC.hmac a (as_seq h0 k) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data))) /\ as_seq h1 v == Spec.Agile.HMAC.hmac a (as_seq h1 k) (as_seq h0 v) /\ modifies2 k v h0 h1) let update_round #a hmac len data n k v = let h0 = ST.get() in push_frame(); let input_len = hash_len a +! 1ul +! len in let input = create input_len (u8 0) in let k' = sub input 0ul (hash_len a) in copy k' v; if len <> 0ul then copy (sub input (hash_len a +! 1ul) len) data; input.(hash_len a) <- n; let h1 = ST.get() in assert (Seq.equal (as_seq h1 input) (Seq.append (as_seq h0 v) (Seq.cons n (as_seq h0 data)))); S.hmac_input_bound a; hmac k' k (hash_len a) input input_len; hmac v k' (hash_len a) v (hash_len a); copy k k'; pop_frame() inline_for_extraction noextract val update: #a:supported_alg -> hmac:HMAC.compute_st a -> len:size_t -> data:lbuffer uint8 len -> k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> Stack unit (requires fun h0 -> live h0 data /\ live h0 k /\ live h0 v /\ disjoint k v /\ disjoint k data /\ disjoint v data /\ hash_length a + 1 + uint_v len + block_length a < pow2 32) (ensures fun h0 _ h1 -> S.hmac_input_bound a; let k', v' = S.update #a (as_seq h0 data) (as_seq h0 k) (as_seq h0 v) in modifies2 k v h0 h1 /\ as_seq h1 k == k' /\ as_seq h1 v == v') let update #a hmac len data k v = update_round hmac len data (u8 0) k v; if len <> 0ul then update_round hmac len data (u8 1) k v noeq type state (a:supported_alg) = | State: k:lbuffer uint8 (hash_len a) -> v:lbuffer uint8 (hash_len a) -> reseed_counter:lbuffer size_t 1ul {disjoint k v /\ disjoint k reseed_counter /\ disjoint v reseed_counter} -> state a let freeable #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.freeable k /\ B.freeable v /\ B.freeable ctr let footprint #a st = let k:B.buffer uint8 = st.k in let v:B.buffer uint8 = st.v in let ctr:B.buffer size_t = st.reseed_counter in B.loc_addr_of_buffer k |+| B.loc_addr_of_buffer v |+| B.loc_addr_of_buffer ctr let invariant #a st h = live h st.k /\ live h st.v /\ live h st.reseed_counter /\ ( // JP: the disjoint predicate from lib hardcodes loc_buffer instead of // loc_addr_of_buffer, which prevents us from writing a proper free function // (probably why it wasn't written here in the first place)... we add on top // of the lib-style predicate a non-lib-style predicate which allows writing // an actual free function let k = st.k <: B.buffer uint8 in let v = st.v <: B.buffer uint8 in let ctr = st.reseed_counter <: B.buffer size_t in B.(all_disjoint [ loc_addr_of_buffer k; loc_addr_of_buffer v; loc_addr_of_buffer ctr ])) let repr #a st h = S.State (as_seq h st.k) (as_seq h st.v) (v (bget h st.reseed_counter 0)) let alloca a = let k = match a with | SHA1 -> create (hash_len SHA1) (u8 0) | SHA2_256 -> create (hash_len SHA2_256) (u8 0) | SHA2_384 -> create (hash_len SHA2_384) (u8 0) | SHA2_512 -> create (hash_len SHA2_512) (u8 0) in let v = match a with | SHA1 -> create (hash_len SHA1) (u8 0) | SHA2_256 -> create (hash_len SHA2_256) (u8 0) | SHA2_384 -> create (hash_len SHA2_384) (u8 0) | SHA2_512 -> create (hash_len SHA2_512) (u8 0) in let ctr = create 1ul 1ul in State k v ctr let create_in a r = let k:B.buffer uint8 = match a with | SHA1 -> B.malloc r (u8 0) (hash_len SHA1) | SHA2_256 -> B.malloc r (u8 0) (hash_len SHA2_256) | SHA2_384 -> B.malloc r (u8 0) (hash_len SHA2_384) | SHA2_512 -> B.malloc r (u8 0) (hash_len SHA2_512) in let v:B.buffer uint8 = match a with | SHA1 -> B.malloc r (u8 0) (hash_len SHA1) | SHA2_256 -> B.malloc r (u8 0) (hash_len SHA2_256) | SHA2_384 -> B.malloc r (u8 0) (hash_len SHA2_384) | SHA2_512 -> B.malloc r (u8 0) (hash_len SHA2_512) in let ctr:B.buffer size_t = B.malloc r 1ul 1ul in State k v ctr #push-options "--z3rlimit 200" let mk_instantiate #a hmac st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string = let h0 = ST.get () in push_frame(); let seed_material = create (entropy_input_len +! nonce_len +! personalization_string_len) (u8 0) in copy (sub seed_material 0ul entropy_input_len) entropy_input; copy (sub seed_material entropy_input_len nonce_len) nonce; copy (sub seed_material (entropy_input_len +! nonce_len) personalization_string_len) personalization_string; let State k v ctr = st in memset k (u8 0) (hash_len a); memset v (u8 1) (hash_len a); let h1 = ST.get () in assert (Seq.equal (as_seq h1 seed_material) (Seq.append (as_seq h0 entropy_input) (Seq.append (as_seq h0 nonce) (as_seq h0 personalization_string)))); assert (LSeq.equal (as_seq h1 k) (LSeq.create (hash_length a) (u8 0))); assert (LSeq.equal (as_seq h1 v) (LSeq.create (hash_length a) (u8 1))); ctr.(0ul) <- 1ul; update hmac (entropy_input_len +! nonce_len +! personalization_string_len) seed_material k v; pop_frame() #pop-options let instantiate a st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string = match a with | SHA1 -> mk_instantiate Hacl.HMAC.compute_sha1 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_256 -> mk_instantiate Hacl.HMAC.compute_sha2_256 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_384 -> mk_instantiate Hacl.HMAC.compute_sha2_384 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string | SHA2_512 -> mk_instantiate Hacl.HMAC.compute_sha2_512 st entropy_input_len entropy_input nonce_len nonce personalization_string_len personalization_string
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fst.checked", "Spec.HMAC_DRBG.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.HMAC.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.HMAC_DRBG.fst" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
hmac: Hacl.HMAC.compute_st a -> Hacl.HMAC_DRBG.reseed_st a
Prims.Tot
[ "total" ]
[]
[ "Hacl.HMAC_DRBG.supported_alg", "Hacl.HMAC.compute_st", "Hacl.HMAC_DRBG.state", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.HMAC_DRBG.hash_len", "FStar.UInt32.__uint_to_t", "Prims.l_and", "Lib.Buffer.disjoint", "Lib.Buffer.MUT", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Lib.Buffer.op_Array_Assignment", "Hacl.HMAC_DRBG.update", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Sequence.eq_intro", "Lib.IntTypes.v", "Lib.Buffer.as_seq", "Lib.Sequence.op_At_Bar", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.copy", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.sub", "Lib.IntTypes.add", "Lib.Buffer.create", "Lib.IntTypes.u8", "FStar.HyperStack.ST.push_frame" ]
[]
false
false
false
false
false
let mk_reseed #a hmac st entropy_input_len entropy_input additional_input_len additional_input =
let h0 = ST.get () in push_frame (); let seed_material = create (entropy_input_len +! additional_input_len) (u8 0) in copy (sub seed_material 0ul entropy_input_len) entropy_input; copy (sub seed_material entropy_input_len additional_input_len) additional_input; let h1 = ST.get () in LSeq.eq_intro (as_seq h1 seed_material) LSeq.(as_seq h0 entropy_input @| as_seq h0 additional_input); let State k v ctr:state a = st in update hmac (entropy_input_len +! additional_input_len) seed_material k v; ctr.(0ul) <- 1ul; pop_frame ()
false
Vale.X64.StateLemmas.fsti
Vale.X64.StateLemmas.machine_eval_code
val machine_eval_code : c: Vale.X64.Machine_Semantics_s.code -> fuel: Prims.nat -> s: Vale.X64.Machine_Semantics_s.machine_state -> Prims.Tot (FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state)
let machine_eval_code = Ms.machine_eval_code
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 51, "end_line": 19, "start_col": 7, "start_line": 19 }
module Vale.X64.StateLemmas open Vale.X64.Machine_s open Vale.Arch.Heap open Vale.X64.State open FStar.FunctionalExtensionality module Ms = Vale.X64.Machine_Semantics_s //open Vale.X64.Machine_Semantics_s //module ME = Vale.X64.Memory open Vale.X64.Memory open Vale.Arch.MachineHeap_s //module MS = Vale.X64.Memory_Sems module VSS = Vale.X64.Stack_Sems module F = FStar.FunctionalExtensionality open Vale.Def.Prop_s open FStar.Mul unfold let machine_state = Ms.machine_state
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Regs.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.StateLemmas.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "Ms" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
c: Vale.X64.Machine_Semantics_s.code -> fuel: Prims.nat -> s: Vale.X64.Machine_Semantics_s.machine_state -> Prims.Tot (FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state)
Prims.Tot
[ "total", "" ]
[]
[ "Vale.X64.Machine_Semantics_s.machine_eval_code" ]
[]
false
false
false
true
false
let machine_eval_code =
Ms.machine_eval_code
false
Vale.X64.StateLemmas.fsti
Vale.X64.StateLemmas.code
val code : Type0
let code = Ms.code
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 18, "start_col": 7, "start_line": 18 }
module Vale.X64.StateLemmas open Vale.X64.Machine_s open Vale.Arch.Heap open Vale.X64.State open FStar.FunctionalExtensionality module Ms = Vale.X64.Machine_Semantics_s //open Vale.X64.Machine_Semantics_s //module ME = Vale.X64.Memory open Vale.X64.Memory open Vale.Arch.MachineHeap_s //module MS = Vale.X64.Memory_Sems module VSS = Vale.X64.Stack_Sems module F = FStar.FunctionalExtensionality open Vale.Def.Prop_s open FStar.Mul
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Regs.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.StateLemmas.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "Ms" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Machine_Semantics_s.code" ]
[]
false
false
false
true
true
let code =
Ms.code
false
Vale.X64.StateLemmas.fsti
Vale.X64.StateLemmas.machine_state_equal
val machine_state_equal : s1: Vale.X64.StateLemmas.machine_state -> s2: Vale.X64.StateLemmas.machine_state -> Prims.logical
let machine_state_equal (s1 s2:machine_state) = let open Vale.X64.Machine_Semantics_s in s1.ms_ok == s2.ms_ok /\ F.feq s1.ms_regs s2.ms_regs /\ F.feq s1.ms_flags s2.ms_flags /\ s1.ms_heap == s2.ms_heap /\ s1.ms_stack == s2.ms_stack /\ s1.ms_stackTaint == s2.ms_stackTaint /\ s1.ms_trace == s2.ms_trace /\ True
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 6, "end_line": 35, "start_col": 0, "start_line": 26 }
module Vale.X64.StateLemmas open Vale.X64.Machine_s open Vale.Arch.Heap open Vale.X64.State open FStar.FunctionalExtensionality module Ms = Vale.X64.Machine_Semantics_s //open Vale.X64.Machine_Semantics_s //module ME = Vale.X64.Memory open Vale.X64.Memory open Vale.Arch.MachineHeap_s //module MS = Vale.X64.Memory_Sems module VSS = Vale.X64.Stack_Sems module F = FStar.FunctionalExtensionality open Vale.Def.Prop_s open FStar.Mul unfold let machine_state = Ms.machine_state unfold let code = Ms.code unfold let machine_eval_code = Ms.machine_eval_code val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x let machine_state_eq (s1 s2:machine_state) = s1 == s2
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Regs.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.StateLemmas.fsti" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.X64.Stack_i", "short_module": "VST" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.X64.Memory_Sems", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "Ms" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
s1: Vale.X64.StateLemmas.machine_state -> s2: Vale.X64.StateLemmas.machine_state -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.StateLemmas.machine_state", "Prims.l_and", "Prims.eq2", "Prims.bool", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok", "FStar.FunctionalExtensionality.feq", "Vale.X64.Machine_s.reg", "Vale.X64.Machine_s.t_reg", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_s.flag", "Vale.X64.Machine_Semantics_s.flag_val_t", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags", "Vale.Arch.Heap.heap_impl", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.machine_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.Arch.HeapTypes_s.memTaint_t", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Prims.list", "Vale.X64.Machine_s.observation", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace", "Prims.l_True", "Prims.logical" ]
[]
false
false
false
true
true
let machine_state_equal (s1 s2: machine_state) =
let open Vale.X64.Machine_Semantics_s in s1.ms_ok == s2.ms_ok /\ F.feq s1.ms_regs s2.ms_regs /\ F.feq s1.ms_flags s2.ms_flags /\ s1.ms_heap == s2.ms_heap /\ s1.ms_stack == s2.ms_stack /\ s1.ms_stackTaint == s2.ms_stackTaint /\ s1.ms_trace == s2.ms_trace /\ True
false
Vale.X64.StateLemmas.fsti
Vale.X64.StateLemmas.machine_state_eq
val machine_state_eq : s1: Vale.X64.StateLemmas.machine_state -> s2: Vale.X64.StateLemmas.machine_state -> Prims.logical
let machine_state_eq (s1 s2:machine_state) = s1 == s2
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 10, "end_line": 24, "start_col": 0, "start_line": 23 }
module Vale.X64.StateLemmas open Vale.X64.Machine_s open Vale.Arch.Heap open Vale.X64.State open FStar.FunctionalExtensionality module Ms = Vale.X64.Machine_Semantics_s //open Vale.X64.Machine_Semantics_s //module ME = Vale.X64.Memory open Vale.X64.Memory open Vale.Arch.MachineHeap_s //module MS = Vale.X64.Memory_Sems module VSS = Vale.X64.Stack_Sems module F = FStar.FunctionalExtensionality open Vale.Def.Prop_s open FStar.Mul unfold let machine_state = Ms.machine_state unfold let code = Ms.code unfold let machine_eval_code = Ms.machine_eval_code val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Regs.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.StateLemmas.fsti" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.X64.Stack_i", "short_module": "VST" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.X64.Memory_Sems", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "Ms" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
s1: Vale.X64.StateLemmas.machine_state -> s2: Vale.X64.StateLemmas.machine_state -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.StateLemmas.machine_state", "Prims.eq2", "Prims.logical" ]
[]
false
false
false
true
true
let machine_state_eq (s1 s2: machine_state) =
s1 == s2
false
Vale.PPC64LE.StateLemmas.fst
Vale.PPC64LE.StateLemmas.lemma_load_buffer_read64
val lemma_load_buffer_read64 (h:vale_heap) (b:buffer64) (i:int) : Lemma (requires valid_buffer_read h b i) (ensures buffer_read b i h == load_mem64 (buffer_addr b h + 8 * i) h) [SMTPat (buffer_read b i h)]
val lemma_load_buffer_read64 (h:vale_heap) (b:buffer64) (i:int) : Lemma (requires valid_buffer_read h b i) (ensures buffer_read b i h == load_mem64 (buffer_addr b h + 8 * i) h) [SMTPat (buffer_read b i h)]
let lemma_load_buffer_read64 h b i = lemma_load_mem64 b i h
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.StateLemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 34, "start_col": 0, "start_line": 33 }
module Vale.PPC64LE.StateLemmas open Vale.PPC64LE.Memory_Sems open Vale.PPC64LE.Memory #reset-options "--initial_fuel 2 --max_fuel 2" let lemma_to_eval_reg s r = () let lemma_to_eval_vec s v = () let lemma_to_eval_maddr s m = () let lemma_to_eval_cmp_opr s o = () let lemma_to_valid_maddr64 s m = () let lemma_valid_mem_addr64 h ptr = bytes_valid64 ptr (get_vale_heap h); lemma_heap_get_heap h; () let lemma_valid_mem_addr128 h ptr = bytes_valid128 ptr (get_vale_heap h); lemma_heap_get_heap h; () let lemma_load_mem_get64 h ptr = equiv_load_mem64 ptr (get_vale_heap h); lemma_heap_get_heap h; () let lemma_load_mem_get128 h ptr = equiv_load_mem128 ptr (get_vale_heap h); lemma_heap_get_heap h; ()
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Memory_Sems.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.StateLemmas.fst" }
[ { "abbrev": false, "full_module": "Vale.PPC64LE.Memory_Sems", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 2, "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.PPC64LE.Memory.vale_heap -> b: Vale.PPC64LE.Memory.buffer64 -> i: Prims.int -> FStar.Pervasives.Lemma (requires Vale.PPC64LE.Memory.valid_buffer_read h b i) (ensures Vale.PPC64LE.Memory.buffer_read b i h == Vale.PPC64LE.Memory.load_mem64 (Vale.PPC64LE.Memory.buffer_addr b h + 8 * i) h) [SMTPat (Vale.PPC64LE.Memory.buffer_read b i h)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.PPC64LE.Memory.vale_heap", "Vale.PPC64LE.Memory.buffer64", "Prims.int", "Vale.PPC64LE.Memory.lemma_load_mem64", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_load_buffer_read64 h b i =
lemma_load_mem64 b i h
false
Vale.PPC64LE.StateLemmas.fst
Vale.PPC64LE.StateLemmas.lemma_load_buffer_read128
val lemma_load_buffer_read128 (h:vale_heap) (b:buffer128) (i:int) : Lemma (requires valid_buffer_read h b i) (ensures buffer_read b i h == load_mem128 (buffer_addr b h + 16 * i) h) [SMTPat (buffer_read b i h)]
val lemma_load_buffer_read128 (h:vale_heap) (b:buffer128) (i:int) : Lemma (requires valid_buffer_read h b i) (ensures buffer_read b i h == load_mem128 (buffer_addr b h + 16 * i) h) [SMTPat (buffer_read b i h)]
let lemma_load_buffer_read128 h b i = lemma_load_mem128 b i h
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.StateLemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 37, "start_col": 0, "start_line": 36 }
module Vale.PPC64LE.StateLemmas open Vale.PPC64LE.Memory_Sems open Vale.PPC64LE.Memory #reset-options "--initial_fuel 2 --max_fuel 2" let lemma_to_eval_reg s r = () let lemma_to_eval_vec s v = () let lemma_to_eval_maddr s m = () let lemma_to_eval_cmp_opr s o = () let lemma_to_valid_maddr64 s m = () let lemma_valid_mem_addr64 h ptr = bytes_valid64 ptr (get_vale_heap h); lemma_heap_get_heap h; () let lemma_valid_mem_addr128 h ptr = bytes_valid128 ptr (get_vale_heap h); lemma_heap_get_heap h; () let lemma_load_mem_get64 h ptr = equiv_load_mem64 ptr (get_vale_heap h); lemma_heap_get_heap h; () let lemma_load_mem_get128 h ptr = equiv_load_mem128 ptr (get_vale_heap h); lemma_heap_get_heap h; () let lemma_load_buffer_read64 h b i = lemma_load_mem64 b i h
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Memory_Sems.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.StateLemmas.fst" }
[ { "abbrev": false, "full_module": "Vale.PPC64LE.Memory_Sems", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 2, "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.PPC64LE.Memory.vale_heap -> b: Vale.PPC64LE.Memory.buffer128 -> i: Prims.int -> FStar.Pervasives.Lemma (requires Vale.PPC64LE.Memory.valid_buffer_read h b i) (ensures Vale.PPC64LE.Memory.buffer_read b i h == Vale.PPC64LE.Memory.load_mem128 (Vale.PPC64LE.Memory.buffer_addr b h + 16 * i) h) [SMTPat (Vale.PPC64LE.Memory.buffer_read b i h)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.PPC64LE.Memory.vale_heap", "Vale.PPC64LE.Memory.buffer128", "Prims.int", "Vale.PPC64LE.Memory.lemma_load_mem128", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_load_buffer_read128 h b i =
lemma_load_mem128 b i h
false
CDDL.Pulse.fst
CDDL.Pulse.impl_t_choice_none
val impl_t_choice_none (#t1 #t2: bounded_typ_gen None) (f1: impl_typ t1) (f2: impl_typ t2) : Tot (impl_typ (t_choice t1 t2))
val impl_t_choice_none (#t1 #t2: bounded_typ_gen None) (f1: impl_typ t1) (f2: impl_typ t2) : Tot (impl_typ (t_choice t1 t2))
let impl_t_choice_none // FIXME: WHY WHY WHY can F* not automatically infer t1 and t2 by reducing (reveal (hide None)) to None? (#t1 #t2: bounded_typ_gen None) (f1: impl_typ t1) (f2: impl_typ t2) : Tot (impl_typ (t_choice t1 t2)) = impl_t_choice #None #t1 #t2 f1 f2
{ "file_name": "share/steel/examples/pulse/dice/cbor/CDDL.Pulse.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 35, "end_line": 87, "start_col": 0, "start_line": 82 }
(* 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 CDDL.Pulse open Pulse.Lib.Pervasives open Pulse.Lib.Stick open CBOR.Spec open CBOR.Pulse open CDDL.Spec module R = Pulse.Lib.Reference inline_for_extraction noextract [@@noextract_to "krml"] let impl_typ (#b: option raw_data_item) (t: bounded_typ_gen b) = (c: cbor) -> (#p: perm) -> (#v: Ghost.erased raw_data_item) -> stt bool (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b )) (fun res -> raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b /\ res == t v )) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_coerce_to_bounded_typ (b: Ghost.erased (option raw_data_item)) (#t: typ) (f: impl_typ t) : impl_typ #b (coerce_to_bounded_typ b t) // FIXME: WHY WHY WHY do I need to provide the implicit argument = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { f c; } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_choice (#b: Ghost.erased (option raw_data_item)) (#t1 #t2: bounded_typ_gen b) (f1: impl_typ t1) (f2: impl_typ t2) : impl_typ #b (t_choice t1 t2) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let test = f1 c; if (test) { true } else { f2 c } } ```
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Stick.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CDDL.Spec.fsti.checked", "CBOR.Spec.fsti.checked", "CBOR.Pulse.fst.checked" ], "interface_file": false, "source_file": "CDDL.Pulse.fst" }
[ { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "CDDL.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Pulse", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Stick", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
f1: CDDL.Pulse.impl_typ t1 -> f2: CDDL.Pulse.impl_typ t2 -> CDDL.Pulse.impl_typ (CDDL.Spec.t_choice t1 t2)
Prims.Tot
[ "total" ]
[]
[ "CDDL.Spec.bounded_typ_gen", "FStar.Pervasives.Native.None", "CBOR.Spec.Type.raw_data_item", "CDDL.Pulse.impl_typ", "CDDL.Pulse.impl_t_choice", "FStar.Ghost.hide", "FStar.Pervasives.Native.option", "CDDL.Spec.t_choice" ]
[]
false
false
false
false
false
let impl_t_choice_none (#t1 #t2: bounded_typ_gen None) (f1: impl_typ t1) (f2: impl_typ t2) : Tot (impl_typ (t_choice t1 t2)) =
impl_t_choice #None #t1 #t2 f1 f2
false
Vale.PPC64LE.StateLemmas.fst
Vale.PPC64LE.StateLemmas.lemma_load_mem_get128
val lemma_load_mem_get128 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem128 ptr (get_vale_heap h)) (ensures load_mem128 ptr (get_vale_heap h) == S.get_heap_val128 ptr (heap_get (coerce h))) [SMTPat (load_mem128 ptr (get_vale_heap h))]
val lemma_load_mem_get128 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem128 ptr (get_vale_heap h)) (ensures load_mem128 ptr (get_vale_heap h) == S.get_heap_val128 ptr (heap_get (coerce h))) [SMTPat (load_mem128 ptr (get_vale_heap h))]
let lemma_load_mem_get128 h ptr = equiv_load_mem128 ptr (get_vale_heap h); lemma_heap_get_heap h; ()
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.StateLemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 31, "start_col": 0, "start_line": 28 }
module Vale.PPC64LE.StateLemmas open Vale.PPC64LE.Memory_Sems open Vale.PPC64LE.Memory #reset-options "--initial_fuel 2 --max_fuel 2" let lemma_to_eval_reg s r = () let lemma_to_eval_vec s v = () let lemma_to_eval_maddr s m = () let lemma_to_eval_cmp_opr s o = () let lemma_to_valid_maddr64 s m = () let lemma_valid_mem_addr64 h ptr = bytes_valid64 ptr (get_vale_heap h); lemma_heap_get_heap h; () let lemma_valid_mem_addr128 h ptr = bytes_valid128 ptr (get_vale_heap h); lemma_heap_get_heap h; () let lemma_load_mem_get64 h ptr = equiv_load_mem64 ptr (get_vale_heap h); lemma_heap_get_heap h; ()
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Memory_Sems.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.StateLemmas.fst" }
[ { "abbrev": false, "full_module": "Vale.PPC64LE.Memory_Sems", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 2, "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.PPC64LE.Memory.vale_full_heap -> ptr: Prims.int -> FStar.Pervasives.Lemma (requires Vale.PPC64LE.Memory.valid_mem128 ptr (Vale.PPC64LE.Memory.get_vale_heap h)) (ensures Vale.PPC64LE.Memory.load_mem128 ptr (Vale.PPC64LE.Memory.get_vale_heap h) == Vale.Arch.MachineHeap_s.get_heap_val128 ptr (Vale.Arch.Heap.heap_get (Vale.PPC64LE.Memory_Sems.coerce h))) [SMTPat (Vale.PPC64LE.Memory.load_mem128 ptr (Vale.PPC64LE.Memory.get_vale_heap h))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.PPC64LE.Memory.vale_full_heap", "Prims.int", "Prims.unit", "Vale.PPC64LE.Memory_Sems.lemma_heap_get_heap", "Vale.PPC64LE.Memory_Sems.equiv_load_mem128", "Vale.PPC64LE.Memory.get_vale_heap" ]
[]
true
false
true
false
false
let lemma_load_mem_get128 h ptr =
equiv_load_mem128 ptr (get_vale_heap h); lemma_heap_get_heap h; ()
false
Vale.PPC64LE.StateLemmas.fst
Vale.PPC64LE.StateLemmas.lemma_valid_mem_addr128
val lemma_valid_mem_addr128 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem128 ptr (get_vale_heap h)) (ensures S.valid_addr128 ptr (heap_get (coerce h))) [SMTPat (valid_mem128 ptr (get_vale_heap h))]
val lemma_valid_mem_addr128 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem128 ptr (get_vale_heap h)) (ensures S.valid_addr128 ptr (heap_get (coerce h))) [SMTPat (valid_mem128 ptr (get_vale_heap h))]
let lemma_valid_mem_addr128 h ptr = bytes_valid128 ptr (get_vale_heap h); lemma_heap_get_heap h; ()
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.StateLemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 21, "start_col": 0, "start_line": 18 }
module Vale.PPC64LE.StateLemmas open Vale.PPC64LE.Memory_Sems open Vale.PPC64LE.Memory #reset-options "--initial_fuel 2 --max_fuel 2" let lemma_to_eval_reg s r = () let lemma_to_eval_vec s v = () let lemma_to_eval_maddr s m = () let lemma_to_eval_cmp_opr s o = () let lemma_to_valid_maddr64 s m = () let lemma_valid_mem_addr64 h ptr = bytes_valid64 ptr (get_vale_heap h); lemma_heap_get_heap h; ()
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Memory_Sems.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.StateLemmas.fst" }
[ { "abbrev": false, "full_module": "Vale.PPC64LE.Memory_Sems", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 2, "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.PPC64LE.Memory.vale_full_heap -> ptr: Prims.int -> FStar.Pervasives.Lemma (requires Vale.PPC64LE.Memory.valid_mem128 ptr (Vale.PPC64LE.Memory.get_vale_heap h)) (ensures Vale.Arch.MachineHeap_s.valid_addr128 ptr (Vale.Arch.Heap.heap_get (Vale.PPC64LE.Memory_Sems.coerce h))) [SMTPat (Vale.PPC64LE.Memory.valid_mem128 ptr (Vale.PPC64LE.Memory.get_vale_heap h))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.PPC64LE.Memory.vale_full_heap", "Prims.int", "Prims.unit", "Vale.PPC64LE.Memory_Sems.lemma_heap_get_heap", "Vale.PPC64LE.Memory_Sems.bytes_valid128", "Vale.PPC64LE.Memory.get_vale_heap" ]
[]
true
false
true
false
false
let lemma_valid_mem_addr128 h ptr =
bytes_valid128 ptr (get_vale_heap h); lemma_heap_get_heap h; ()
false
CDDL.Pulse.fst
CDDL.Pulse.impl_uint_literal
val impl_uint_literal (n: U64.t) : impl_typ (t_uint_literal n)
val impl_uint_literal (n: U64.t) : impl_typ (t_uint_literal n)
let impl_uint_literal (n: U64.t) : impl_typ (t_uint_literal n) = impl_uint_literal' n
{ "file_name": "share/steel/examples/pulse/dice/cbor/CDDL.Pulse.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 22, "end_line": 175, "start_col": 0, "start_line": 172 }
(* 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 CDDL.Pulse open Pulse.Lib.Pervasives open Pulse.Lib.Stick open CBOR.Spec open CBOR.Pulse open CDDL.Spec module R = Pulse.Lib.Reference inline_for_extraction noextract [@@noextract_to "krml"] let impl_typ (#b: option raw_data_item) (t: bounded_typ_gen b) = (c: cbor) -> (#p: perm) -> (#v: Ghost.erased raw_data_item) -> stt bool (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b )) (fun res -> raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b /\ res == t v )) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_coerce_to_bounded_typ (b: Ghost.erased (option raw_data_item)) (#t: typ) (f: impl_typ t) : impl_typ #b (coerce_to_bounded_typ b t) // FIXME: WHY WHY WHY do I need to provide the implicit argument = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { f c; } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_choice (#b: Ghost.erased (option raw_data_item)) (#t1 #t2: bounded_typ_gen b) (f1: impl_typ t1) (f2: impl_typ t2) : impl_typ #b (t_choice t1 t2) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let test = f1 c; if (test) { true } else { f2 c } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_t_choice_none // FIXME: WHY WHY WHY can F* not automatically infer t1 and t2 by reducing (reveal (hide None)) to None? (#t1 #t2: bounded_typ_gen None) (f1: impl_typ t1) (f2: impl_typ t2) : Tot (impl_typ (t_choice t1 t2)) = impl_t_choice #None #t1 #t2 f1 f2 inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_any (_: unit) : impl_typ #None any = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { true } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint (_: unit) : impl_typ #None uint = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_uint64) } ``` module U64 = FStar.UInt64 (* FIXME: WHY WHY WHY does this one not work? inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal (n: U64.t) : impl_typ #None (t_uint_literal n) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; if (mt = major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` *) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal' (n: U64.t) (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) requires (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) )) returns res: bool ensures (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) /\ res == t_uint_literal n v )) { let mt = cbor_get_major_type c; if (mt = cbor_major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ```
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Stick.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CDDL.Spec.fsti.checked", "CBOR.Spec.fsti.checked", "CBOR.Pulse.fst.checked" ], "interface_file": false, "source_file": "CDDL.Pulse.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "CDDL.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Pulse", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Stick", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
n: FStar.UInt64.t -> CDDL.Pulse.impl_typ (CDDL.Spec.t_uint_literal n)
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt64.t", "CDDL.Pulse.impl_uint_literal'", "CDDL.Pulse.impl_typ", "FStar.Pervasives.Native.None", "CBOR.Spec.Type.raw_data_item", "CDDL.Spec.t_uint_literal" ]
[]
false
false
false
false
false
let impl_uint_literal (n: U64.t) : impl_typ (t_uint_literal n) =
impl_uint_literal' n
false
Vale.PPC64LE.StateLemmas.fst
Vale.PPC64LE.StateLemmas.lemma_valid_mem_addr64
val lemma_valid_mem_addr64 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem64 ptr (get_vale_heap h)) (ensures S.valid_addr64 ptr (heap_get (coerce h))) [SMTPat (valid_mem64 ptr (get_vale_heap h))]
val lemma_valid_mem_addr64 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem64 ptr (get_vale_heap h)) (ensures S.valid_addr64 ptr (heap_get (coerce h))) [SMTPat (valid_mem64 ptr (get_vale_heap h))]
let lemma_valid_mem_addr64 h ptr = bytes_valid64 ptr (get_vale_heap h); lemma_heap_get_heap h; ()
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.StateLemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 16, "start_col": 0, "start_line": 13 }
module Vale.PPC64LE.StateLemmas open Vale.PPC64LE.Memory_Sems open Vale.PPC64LE.Memory #reset-options "--initial_fuel 2 --max_fuel 2" let lemma_to_eval_reg s r = () let lemma_to_eval_vec s v = () let lemma_to_eval_maddr s m = () let lemma_to_eval_cmp_opr s o = () let lemma_to_valid_maddr64 s m = ()
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Memory_Sems.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.StateLemmas.fst" }
[ { "abbrev": false, "full_module": "Vale.PPC64LE.Memory_Sems", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 2, "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.PPC64LE.Memory.vale_full_heap -> ptr: Prims.int -> FStar.Pervasives.Lemma (requires Vale.PPC64LE.Memory.valid_mem64 ptr (Vale.PPC64LE.Memory.get_vale_heap h)) (ensures Vale.Arch.MachineHeap_s.valid_addr64 ptr (Vale.Arch.Heap.heap_get (Vale.PPC64LE.Memory_Sems.coerce h))) [SMTPat (Vale.PPC64LE.Memory.valid_mem64 ptr (Vale.PPC64LE.Memory.get_vale_heap h))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.PPC64LE.Memory.vale_full_heap", "Prims.int", "Prims.unit", "Vale.PPC64LE.Memory_Sems.lemma_heap_get_heap", "Vale.PPC64LE.Memory_Sems.bytes_valid64", "Vale.PPC64LE.Memory.get_vale_heap" ]
[]
true
false
true
false
false
let lemma_valid_mem_addr64 h ptr =
bytes_valid64 ptr (get_vale_heap h); lemma_heap_get_heap h; ()
false
CDDL.Pulse.fst
CDDL.Pulse.cbor_read_with_typ_success_post
val cbor_read_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) : Tot vprop
val cbor_read_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) : Tot vprop
let cbor_read_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) : Tot vprop = exists* v rem. raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem ** ((raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem) @==> A.pts_to a #p va) ** pure (cbor_read_with_typ_success_postcond t va c v rem)
{ "file_name": "share/steel/examples/pulse/dice/cbor/CDDL.Pulse.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 59, "end_line": 394, "start_col": 0, "start_line": 382 }
(* 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 CDDL.Pulse open Pulse.Lib.Pervasives open Pulse.Lib.Stick open CBOR.Spec open CBOR.Pulse open CDDL.Spec module R = Pulse.Lib.Reference inline_for_extraction noextract [@@noextract_to "krml"] let impl_typ (#b: option raw_data_item) (t: bounded_typ_gen b) = (c: cbor) -> (#p: perm) -> (#v: Ghost.erased raw_data_item) -> stt bool (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b )) (fun res -> raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b /\ res == t v )) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_coerce_to_bounded_typ (b: Ghost.erased (option raw_data_item)) (#t: typ) (f: impl_typ t) : impl_typ #b (coerce_to_bounded_typ b t) // FIXME: WHY WHY WHY do I need to provide the implicit argument = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { f c; } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_choice (#b: Ghost.erased (option raw_data_item)) (#t1 #t2: bounded_typ_gen b) (f1: impl_typ t1) (f2: impl_typ t2) : impl_typ #b (t_choice t1 t2) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let test = f1 c; if (test) { true } else { f2 c } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_t_choice_none // FIXME: WHY WHY WHY can F* not automatically infer t1 and t2 by reducing (reveal (hide None)) to None? (#t1 #t2: bounded_typ_gen None) (f1: impl_typ t1) (f2: impl_typ t2) : Tot (impl_typ (t_choice t1 t2)) = impl_t_choice #None #t1 #t2 f1 f2 inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_any (_: unit) : impl_typ #None any = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { true } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint (_: unit) : impl_typ #None uint = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_uint64) } ``` module U64 = FStar.UInt64 (* FIXME: WHY WHY WHY does this one not work? inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal (n: U64.t) : impl_typ #None (t_uint_literal n) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; if (mt = major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` *) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal' (n: U64.t) (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) requires (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) )) returns res: bool ensures (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) /\ res == t_uint_literal n v )) { let mt = cbor_get_major_type c; if (mt = cbor_major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_uint_literal (n: U64.t) : impl_typ (t_uint_literal n) = impl_uint_literal' n inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_bytes (_: unit) : impl_typ #None bytes = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_byte_string) } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_array_group3 (#b: Ghost.erased (option raw_data_item)) (g: array_group3 b) = (pi: R.ref cbor_array_iterator_t) -> (#p: perm) -> (#i: Ghost.erased cbor_array_iterator_t) -> (#l: Ghost.erased (list raw_data_item)) -> stt bool (R.pts_to pi i ** cbor_array_iterator_match p i l ** pure (opt_precedes (Ghost.reveal l) b) ) (fun res -> exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ```pulse ghost fn intro_impl_array_group3_post (#b: option raw_data_item) (g: array_group3 b) (pi: R.ref cbor_array_iterator_t) (p: perm) (i: cbor_array_iterator_t) (l: list raw_data_item) (res: bool) (i': cbor_array_iterator_t) (l': list raw_data_item) requires ( R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ensures (exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) { () } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_concat (#b: Ghost.erased (option raw_data_item)) (#g1: array_group3 b) (f1: impl_array_group3 g1) (#g2: array_group3 b) (f2: impl_array_group3 g2) : impl_array_group3 #b (array_group3_concat g1 g2) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let test1 = f1 pi; if (test1) { let test2 = f2 pi; stick_trans (); test2 } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_item (#b: Ghost.erased (option raw_data_item)) (#ty: bounded_typ_gen b) (fty: impl_typ ty) : impl_array_group3 #b (array_group3_item ty) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let i = !pi; rewrite (cbor_array_iterator_match p gi l) as (cbor_array_iterator_match p i l); let is_done = cbor_array_iterator_is_done i; rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p gi l); if (is_done) { stick_refl0 (cbor_array_iterator_match p gi l); intro_impl_array_group3_post (array_group3_item ty) pi p gi l false gi l; // FIXME: WHY WHY WHY? and also WHY WHY WHY here and not in the other "false" case below? false } else { let c = cbor_array_iterator_next pi #p #l #gi; // FIXME: WHY WHY WHY those explicit arguments? with gc i' l' . assert ( raw_data_item_match p c gc ** cbor_array_iterator_match p i' l' ** ((raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') @==> cbor_array_iterator_match p gi l) ); // this is needed for the explicit arguments to split_consume_l below let test = fty c; if (test) { stick_consume_l () #(raw_data_item_match p c gc) #(cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l) // FIXME: WHY WHY WHY those explicit arguments? (for which the with above is needed) ; true } else { elim_stick0 () #(raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l); // FIXME: WHY WHY WHY those explicit arguments? pi := i; rewrite (R.pts_to pi i) as (R.pts_to pi gi); stick_refl0 (cbor_array_iterator_match p gi l); false } } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_array (#b: Ghost.erased (option raw_data_item)) (#g: (array_group3 b)) (ig: (impl_array_group3 (g))) : impl_typ #b (t_array3 g) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let ty = cbor_get_major_type c; if (ty = cbor_major_type_array) { let i = cbor_array_iterator_init c; with l . assert (cbor_array_iterator_match p i l); rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l); let mut pi = i; let b_success = ig pi; with gi' l' . assert (cbor_array_iterator_match p gi' l'); let i' = ! pi; rewrite (cbor_array_iterator_match p gi' l') as (cbor_array_iterator_match p i' l'); let b_end = cbor_array_iterator_is_done i'; rewrite (cbor_array_iterator_match p i' l') as (cbor_array_iterator_match p gi' l'); elim_stick0 (); rewrite (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l) as (cbor_array_iterator_match p i l); elim_stick0 (); (b_success && b_end) } else { false } } ``` module U8 = FStar.UInt8 noextract [@@noextract_to "krml"] let cbor_read_with_typ_success_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Tot prop = cbor_read_success_postcond va c v rem /\ t v == true module A = Pulse.Lib.Array
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Stick.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CDDL.Spec.fsti.checked", "CBOR.Spec.fsti.checked", "CBOR.Pulse.fst.checked" ], "interface_file": false, "source_file": "CDDL.Pulse.fst" }
[ { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "CDDL.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Pulse", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Stick", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: CDDL.Spec.typ -> a: Pulse.Lib.Array.Core.array FStar.UInt8.t -> p: PulseCore.FractionalPermission.perm -> va: FStar.Ghost.erased (FStar.Seq.Base.seq FStar.UInt8.t) -> c: CBOR.Pulse.Extern.cbor_read_t -> Pulse.Lib.Core.vprop
Prims.Tot
[ "total" ]
[]
[ "CDDL.Spec.typ", "Pulse.Lib.Array.Core.array", "FStar.UInt8.t", "PulseCore.FractionalPermission.perm", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "CBOR.Pulse.Extern.cbor_read_t", "Pulse.Lib.Core.op_exists_Star", "CBOR.Spec.Type.raw_data_item", "Pulse.Lib.Core.op_Star_Star", "CBOR.Pulse.Extern.raw_data_item_match", "PulseCore.FractionalPermission.full_perm", "CBOR.Pulse.Extern.__proj__Mkcbor_read_t__item__cbor_read_payload", "Pulse.Lib.Array.Core.pts_to", "CBOR.Pulse.Extern.__proj__Mkcbor_read_t__item__cbor_read_remainder", "Pulse.Lib.Stick.op_At_Equals_Equals_Greater", "FStar.Ghost.reveal", "Pulse.Lib.Core.pure", "CDDL.Pulse.cbor_read_with_typ_success_postcond", "Pulse.Lib.Core.vprop" ]
[]
false
false
false
true
false
let cbor_read_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) : Tot vprop =
exists* v rem. ((raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem) ** ((raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem) @==> A.pts_to a #p va)) ** pure (cbor_read_with_typ_success_postcond t va c v rem)
false
Vale.PPC64LE.StateLemmas.fst
Vale.PPC64LE.StateLemmas.lemma_load_mem_get64
val lemma_load_mem_get64 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem64 ptr (get_vale_heap h)) (ensures load_mem64 ptr (get_vale_heap h) == S.get_heap_val64 ptr (heap_get (coerce h))) [SMTPat (load_mem64 ptr (get_vale_heap h))]
val lemma_load_mem_get64 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem64 ptr (get_vale_heap h)) (ensures load_mem64 ptr (get_vale_heap h) == S.get_heap_val64 ptr (heap_get (coerce h))) [SMTPat (load_mem64 ptr (get_vale_heap h))]
let lemma_load_mem_get64 h ptr = equiv_load_mem64 ptr (get_vale_heap h); lemma_heap_get_heap h; ()
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.StateLemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 26, "start_col": 0, "start_line": 23 }
module Vale.PPC64LE.StateLemmas open Vale.PPC64LE.Memory_Sems open Vale.PPC64LE.Memory #reset-options "--initial_fuel 2 --max_fuel 2" let lemma_to_eval_reg s r = () let lemma_to_eval_vec s v = () let lemma_to_eval_maddr s m = () let lemma_to_eval_cmp_opr s o = () let lemma_to_valid_maddr64 s m = () let lemma_valid_mem_addr64 h ptr = bytes_valid64 ptr (get_vale_heap h); lemma_heap_get_heap h; () let lemma_valid_mem_addr128 h ptr = bytes_valid128 ptr (get_vale_heap h); lemma_heap_get_heap h; ()
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Memory_Sems.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.StateLemmas.fst" }
[ { "abbrev": false, "full_module": "Vale.PPC64LE.Memory_Sems", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 2, "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.PPC64LE.Memory.vale_full_heap -> ptr: Prims.int -> FStar.Pervasives.Lemma (requires Vale.PPC64LE.Memory.valid_mem64 ptr (Vale.PPC64LE.Memory.get_vale_heap h)) (ensures Vale.PPC64LE.Memory.load_mem64 ptr (Vale.PPC64LE.Memory.get_vale_heap h) == Vale.Arch.MachineHeap_s.get_heap_val64 ptr (Vale.Arch.Heap.heap_get (Vale.PPC64LE.Memory_Sems.coerce h))) [SMTPat (Vale.PPC64LE.Memory.load_mem64 ptr (Vale.PPC64LE.Memory.get_vale_heap h))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.PPC64LE.Memory.vale_full_heap", "Prims.int", "Prims.unit", "Vale.PPC64LE.Memory_Sems.lemma_heap_get_heap", "Vale.PPC64LE.Memory_Sems.equiv_load_mem64", "Vale.PPC64LE.Memory.get_vale_heap" ]
[]
true
false
true
false
false
let lemma_load_mem_get64 h ptr =
equiv_load_mem64 ptr (get_vale_heap h); lemma_heap_get_heap h; ()
false
Vale.X64.StateLemmas.fsti
Vale.X64.StateLemmas.coerce
val coerce (#b #a: Type) (x: a{a == b}) : b
val coerce (#b #a: Type) (x: a{a == b}) : b
let coerce (#b #a:Type) (x:a{a == b}) : b = x
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 21, "start_col": 7, "start_line": 21 }
module Vale.X64.StateLemmas open Vale.X64.Machine_s open Vale.Arch.Heap open Vale.X64.State open FStar.FunctionalExtensionality module Ms = Vale.X64.Machine_Semantics_s //open Vale.X64.Machine_Semantics_s //module ME = Vale.X64.Memory open Vale.X64.Memory open Vale.Arch.MachineHeap_s //module MS = Vale.X64.Memory_Sems module VSS = Vale.X64.Stack_Sems module F = FStar.FunctionalExtensionality open Vale.Def.Prop_s open FStar.Mul unfold let machine_state = Ms.machine_state unfold let code = Ms.code unfold let machine_eval_code = Ms.machine_eval_code
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Regs.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.StateLemmas.fsti" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.X64.Stack_i", "short_module": "VST" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.X64.Memory_Sems", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "Ms" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
x: a{a == b} -> b
Prims.Tot
[ "total" ]
[]
[ "Prims.eq2" ]
[]
false
false
false
false
false
let coerce (#b #a: Type) (x: a{a == b}) : b =
x
false
CDDL.Pulse.fst
CDDL.Pulse.cbor_read_with_typ_post
val cbor_read_with_typ_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop
val cbor_read_with_typ_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop
let cbor_read_with_typ_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop = if res.cbor_read_is_success then cbor_read_with_typ_success_post t a p va res else cbor_read_with_typ_error_post t a p va
{ "file_name": "share/steel/examples/pulse/dice/cbor/CDDL.Pulse.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 45, "end_line": 438, "start_col": 0, "start_line": 429 }
(* 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 CDDL.Pulse open Pulse.Lib.Pervasives open Pulse.Lib.Stick open CBOR.Spec open CBOR.Pulse open CDDL.Spec module R = Pulse.Lib.Reference inline_for_extraction noextract [@@noextract_to "krml"] let impl_typ (#b: option raw_data_item) (t: bounded_typ_gen b) = (c: cbor) -> (#p: perm) -> (#v: Ghost.erased raw_data_item) -> stt bool (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b )) (fun res -> raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b /\ res == t v )) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_coerce_to_bounded_typ (b: Ghost.erased (option raw_data_item)) (#t: typ) (f: impl_typ t) : impl_typ #b (coerce_to_bounded_typ b t) // FIXME: WHY WHY WHY do I need to provide the implicit argument = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { f c; } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_choice (#b: Ghost.erased (option raw_data_item)) (#t1 #t2: bounded_typ_gen b) (f1: impl_typ t1) (f2: impl_typ t2) : impl_typ #b (t_choice t1 t2) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let test = f1 c; if (test) { true } else { f2 c } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_t_choice_none // FIXME: WHY WHY WHY can F* not automatically infer t1 and t2 by reducing (reveal (hide None)) to None? (#t1 #t2: bounded_typ_gen None) (f1: impl_typ t1) (f2: impl_typ t2) : Tot (impl_typ (t_choice t1 t2)) = impl_t_choice #None #t1 #t2 f1 f2 inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_any (_: unit) : impl_typ #None any = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { true } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint (_: unit) : impl_typ #None uint = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_uint64) } ``` module U64 = FStar.UInt64 (* FIXME: WHY WHY WHY does this one not work? inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal (n: U64.t) : impl_typ #None (t_uint_literal n) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; if (mt = major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` *) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal' (n: U64.t) (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) requires (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) )) returns res: bool ensures (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) /\ res == t_uint_literal n v )) { let mt = cbor_get_major_type c; if (mt = cbor_major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_uint_literal (n: U64.t) : impl_typ (t_uint_literal n) = impl_uint_literal' n inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_bytes (_: unit) : impl_typ #None bytes = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_byte_string) } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_array_group3 (#b: Ghost.erased (option raw_data_item)) (g: array_group3 b) = (pi: R.ref cbor_array_iterator_t) -> (#p: perm) -> (#i: Ghost.erased cbor_array_iterator_t) -> (#l: Ghost.erased (list raw_data_item)) -> stt bool (R.pts_to pi i ** cbor_array_iterator_match p i l ** pure (opt_precedes (Ghost.reveal l) b) ) (fun res -> exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ```pulse ghost fn intro_impl_array_group3_post (#b: option raw_data_item) (g: array_group3 b) (pi: R.ref cbor_array_iterator_t) (p: perm) (i: cbor_array_iterator_t) (l: list raw_data_item) (res: bool) (i': cbor_array_iterator_t) (l': list raw_data_item) requires ( R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ensures (exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) { () } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_concat (#b: Ghost.erased (option raw_data_item)) (#g1: array_group3 b) (f1: impl_array_group3 g1) (#g2: array_group3 b) (f2: impl_array_group3 g2) : impl_array_group3 #b (array_group3_concat g1 g2) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let test1 = f1 pi; if (test1) { let test2 = f2 pi; stick_trans (); test2 } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_item (#b: Ghost.erased (option raw_data_item)) (#ty: bounded_typ_gen b) (fty: impl_typ ty) : impl_array_group3 #b (array_group3_item ty) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let i = !pi; rewrite (cbor_array_iterator_match p gi l) as (cbor_array_iterator_match p i l); let is_done = cbor_array_iterator_is_done i; rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p gi l); if (is_done) { stick_refl0 (cbor_array_iterator_match p gi l); intro_impl_array_group3_post (array_group3_item ty) pi p gi l false gi l; // FIXME: WHY WHY WHY? and also WHY WHY WHY here and not in the other "false" case below? false } else { let c = cbor_array_iterator_next pi #p #l #gi; // FIXME: WHY WHY WHY those explicit arguments? with gc i' l' . assert ( raw_data_item_match p c gc ** cbor_array_iterator_match p i' l' ** ((raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') @==> cbor_array_iterator_match p gi l) ); // this is needed for the explicit arguments to split_consume_l below let test = fty c; if (test) { stick_consume_l () #(raw_data_item_match p c gc) #(cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l) // FIXME: WHY WHY WHY those explicit arguments? (for which the with above is needed) ; true } else { elim_stick0 () #(raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l); // FIXME: WHY WHY WHY those explicit arguments? pi := i; rewrite (R.pts_to pi i) as (R.pts_to pi gi); stick_refl0 (cbor_array_iterator_match p gi l); false } } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_array (#b: Ghost.erased (option raw_data_item)) (#g: (array_group3 b)) (ig: (impl_array_group3 (g))) : impl_typ #b (t_array3 g) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let ty = cbor_get_major_type c; if (ty = cbor_major_type_array) { let i = cbor_array_iterator_init c; with l . assert (cbor_array_iterator_match p i l); rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l); let mut pi = i; let b_success = ig pi; with gi' l' . assert (cbor_array_iterator_match p gi' l'); let i' = ! pi; rewrite (cbor_array_iterator_match p gi' l') as (cbor_array_iterator_match p i' l'); let b_end = cbor_array_iterator_is_done i'; rewrite (cbor_array_iterator_match p i' l') as (cbor_array_iterator_match p gi' l'); elim_stick0 (); rewrite (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l) as (cbor_array_iterator_match p i l); elim_stick0 (); (b_success && b_end) } else { false } } ``` module U8 = FStar.UInt8 noextract [@@noextract_to "krml"] let cbor_read_with_typ_success_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Tot prop = cbor_read_success_postcond va c v rem /\ t v == true module A = Pulse.Lib.Array let cbor_read_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) : Tot vprop = exists* v rem. raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem ** ((raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem) @==> A.pts_to a #p va) ** pure (cbor_read_with_typ_success_postcond t va c v rem) noextract [@@noextract_to "krml"] let cbor_read_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop = forall v suff . Ghost.reveal va == serialize_cbor v `Seq.append` suff ==> t v == false let cbor_read_with_typ_error_postcond_intro_typ_fail (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Lemma (requires ( cbor_read_success_postcond va c v rem /\ t v == false )) (ensures ( cbor_read_with_typ_error_postcond t va )) = serialize_cbor_with_test_correct v rem (fun v' rem' -> t v' == true) let cbor_read_with_typ_error_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) : Tot vprop = A.pts_to a #p va ** pure (cbor_read_with_typ_error_postcond t va)
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Stick.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CDDL.Spec.fsti.checked", "CBOR.Spec.fsti.checked", "CBOR.Pulse.fst.checked" ], "interface_file": false, "source_file": "CDDL.Pulse.fst" }
[ { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "CDDL.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Pulse", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Stick", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: CDDL.Spec.typ -> a: Pulse.Lib.Array.Core.array FStar.UInt8.t -> p: PulseCore.FractionalPermission.perm -> va: FStar.Ghost.erased (FStar.Seq.Base.seq FStar.UInt8.t) -> res: CBOR.Pulse.Extern.cbor_read_t -> Pulse.Lib.Core.vprop
Prims.Tot
[ "total" ]
[]
[ "CDDL.Spec.typ", "Pulse.Lib.Array.Core.array", "FStar.UInt8.t", "PulseCore.FractionalPermission.perm", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "CBOR.Pulse.Extern.cbor_read_t", "CBOR.Pulse.Extern.__proj__Mkcbor_read_t__item__cbor_read_is_success", "CDDL.Pulse.cbor_read_with_typ_success_post", "Prims.bool", "CDDL.Pulse.cbor_read_with_typ_error_post", "Pulse.Lib.Core.vprop" ]
[]
false
false
false
true
false
let cbor_read_with_typ_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop =
if res.cbor_read_is_success then cbor_read_with_typ_success_post t a p va res else cbor_read_with_typ_error_post t a p va
false
CDDL.Pulse.fst
CDDL.Pulse.cbor_read_with_typ_error_post
val cbor_read_with_typ_error_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) : Tot vprop
val cbor_read_with_typ_error_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) : Tot vprop
let cbor_read_with_typ_error_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) : Tot vprop = A.pts_to a #p va ** pure (cbor_read_with_typ_error_postcond t va)
{ "file_name": "share/steel/examples/pulse/dice/cbor/CDDL.Pulse.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 67, "end_line": 427, "start_col": 0, "start_line": 421 }
(* 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 CDDL.Pulse open Pulse.Lib.Pervasives open Pulse.Lib.Stick open CBOR.Spec open CBOR.Pulse open CDDL.Spec module R = Pulse.Lib.Reference inline_for_extraction noextract [@@noextract_to "krml"] let impl_typ (#b: option raw_data_item) (t: bounded_typ_gen b) = (c: cbor) -> (#p: perm) -> (#v: Ghost.erased raw_data_item) -> stt bool (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b )) (fun res -> raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b /\ res == t v )) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_coerce_to_bounded_typ (b: Ghost.erased (option raw_data_item)) (#t: typ) (f: impl_typ t) : impl_typ #b (coerce_to_bounded_typ b t) // FIXME: WHY WHY WHY do I need to provide the implicit argument = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { f c; } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_choice (#b: Ghost.erased (option raw_data_item)) (#t1 #t2: bounded_typ_gen b) (f1: impl_typ t1) (f2: impl_typ t2) : impl_typ #b (t_choice t1 t2) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let test = f1 c; if (test) { true } else { f2 c } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_t_choice_none // FIXME: WHY WHY WHY can F* not automatically infer t1 and t2 by reducing (reveal (hide None)) to None? (#t1 #t2: bounded_typ_gen None) (f1: impl_typ t1) (f2: impl_typ t2) : Tot (impl_typ (t_choice t1 t2)) = impl_t_choice #None #t1 #t2 f1 f2 inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_any (_: unit) : impl_typ #None any = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { true } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint (_: unit) : impl_typ #None uint = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_uint64) } ``` module U64 = FStar.UInt64 (* FIXME: WHY WHY WHY does this one not work? inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal (n: U64.t) : impl_typ #None (t_uint_literal n) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; if (mt = major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` *) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal' (n: U64.t) (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) requires (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) )) returns res: bool ensures (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) /\ res == t_uint_literal n v )) { let mt = cbor_get_major_type c; if (mt = cbor_major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_uint_literal (n: U64.t) : impl_typ (t_uint_literal n) = impl_uint_literal' n inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_bytes (_: unit) : impl_typ #None bytes = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_byte_string) } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_array_group3 (#b: Ghost.erased (option raw_data_item)) (g: array_group3 b) = (pi: R.ref cbor_array_iterator_t) -> (#p: perm) -> (#i: Ghost.erased cbor_array_iterator_t) -> (#l: Ghost.erased (list raw_data_item)) -> stt bool (R.pts_to pi i ** cbor_array_iterator_match p i l ** pure (opt_precedes (Ghost.reveal l) b) ) (fun res -> exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ```pulse ghost fn intro_impl_array_group3_post (#b: option raw_data_item) (g: array_group3 b) (pi: R.ref cbor_array_iterator_t) (p: perm) (i: cbor_array_iterator_t) (l: list raw_data_item) (res: bool) (i': cbor_array_iterator_t) (l': list raw_data_item) requires ( R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ensures (exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) { () } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_concat (#b: Ghost.erased (option raw_data_item)) (#g1: array_group3 b) (f1: impl_array_group3 g1) (#g2: array_group3 b) (f2: impl_array_group3 g2) : impl_array_group3 #b (array_group3_concat g1 g2) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let test1 = f1 pi; if (test1) { let test2 = f2 pi; stick_trans (); test2 } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_item (#b: Ghost.erased (option raw_data_item)) (#ty: bounded_typ_gen b) (fty: impl_typ ty) : impl_array_group3 #b (array_group3_item ty) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let i = !pi; rewrite (cbor_array_iterator_match p gi l) as (cbor_array_iterator_match p i l); let is_done = cbor_array_iterator_is_done i; rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p gi l); if (is_done) { stick_refl0 (cbor_array_iterator_match p gi l); intro_impl_array_group3_post (array_group3_item ty) pi p gi l false gi l; // FIXME: WHY WHY WHY? and also WHY WHY WHY here and not in the other "false" case below? false } else { let c = cbor_array_iterator_next pi #p #l #gi; // FIXME: WHY WHY WHY those explicit arguments? with gc i' l' . assert ( raw_data_item_match p c gc ** cbor_array_iterator_match p i' l' ** ((raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') @==> cbor_array_iterator_match p gi l) ); // this is needed for the explicit arguments to split_consume_l below let test = fty c; if (test) { stick_consume_l () #(raw_data_item_match p c gc) #(cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l) // FIXME: WHY WHY WHY those explicit arguments? (for which the with above is needed) ; true } else { elim_stick0 () #(raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l); // FIXME: WHY WHY WHY those explicit arguments? pi := i; rewrite (R.pts_to pi i) as (R.pts_to pi gi); stick_refl0 (cbor_array_iterator_match p gi l); false } } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_array (#b: Ghost.erased (option raw_data_item)) (#g: (array_group3 b)) (ig: (impl_array_group3 (g))) : impl_typ #b (t_array3 g) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let ty = cbor_get_major_type c; if (ty = cbor_major_type_array) { let i = cbor_array_iterator_init c; with l . assert (cbor_array_iterator_match p i l); rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l); let mut pi = i; let b_success = ig pi; with gi' l' . assert (cbor_array_iterator_match p gi' l'); let i' = ! pi; rewrite (cbor_array_iterator_match p gi' l') as (cbor_array_iterator_match p i' l'); let b_end = cbor_array_iterator_is_done i'; rewrite (cbor_array_iterator_match p i' l') as (cbor_array_iterator_match p gi' l'); elim_stick0 (); rewrite (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l) as (cbor_array_iterator_match p i l); elim_stick0 (); (b_success && b_end) } else { false } } ``` module U8 = FStar.UInt8 noextract [@@noextract_to "krml"] let cbor_read_with_typ_success_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Tot prop = cbor_read_success_postcond va c v rem /\ t v == true module A = Pulse.Lib.Array let cbor_read_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) : Tot vprop = exists* v rem. raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem ** ((raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem) @==> A.pts_to a #p va) ** pure (cbor_read_with_typ_success_postcond t va c v rem) noextract [@@noextract_to "krml"] let cbor_read_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop = forall v suff . Ghost.reveal va == serialize_cbor v `Seq.append` suff ==> t v == false let cbor_read_with_typ_error_postcond_intro_typ_fail (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Lemma (requires ( cbor_read_success_postcond va c v rem /\ t v == false )) (ensures ( cbor_read_with_typ_error_postcond t va )) = serialize_cbor_with_test_correct v rem (fun v' rem' -> t v' == true)
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Stick.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CDDL.Spec.fsti.checked", "CBOR.Spec.fsti.checked", "CBOR.Pulse.fst.checked" ], "interface_file": false, "source_file": "CDDL.Pulse.fst" }
[ { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "CDDL.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Pulse", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Stick", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: CDDL.Spec.typ -> a: Pulse.Lib.Array.Core.array FStar.UInt8.t -> p: PulseCore.FractionalPermission.perm -> va: FStar.Ghost.erased (FStar.Seq.Base.seq FStar.UInt8.t) -> Pulse.Lib.Core.vprop
Prims.Tot
[ "total" ]
[]
[ "CDDL.Spec.typ", "Pulse.Lib.Array.Core.array", "FStar.UInt8.t", "PulseCore.FractionalPermission.perm", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Pulse.Lib.Core.op_Star_Star", "Pulse.Lib.Array.Core.pts_to", "FStar.Ghost.reveal", "Pulse.Lib.Core.pure", "CDDL.Pulse.cbor_read_with_typ_error_postcond", "Pulse.Lib.Core.vprop" ]
[]
false
false
false
true
false
let cbor_read_with_typ_error_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) : Tot vprop =
A.pts_to a #p va ** pure (cbor_read_with_typ_error_postcond t va)
false
CDDL.Pulse.fst
CDDL.Pulse.cbor_read_deterministically_encoded_with_typ_success_post
val cbor_read_deterministically_encoded_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop
val cbor_read_deterministically_encoded_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop
let cbor_read_deterministically_encoded_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop = exists* v rem. raw_data_item_match full_perm res.cbor_read_payload v ** A.pts_to res.cbor_read_remainder #p rem ** ((raw_data_item_match full_perm res.cbor_read_payload v ** A.pts_to res.cbor_read_remainder #p rem) @==> A.pts_to a #p va) ** pure (cbor_read_deterministically_encoded_with_typ_success_postcond t va res v rem)
{ "file_name": "share/steel/examples/pulse/dice/cbor/CDDL.Pulse.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 91, "end_line": 544, "start_col": 0, "start_line": 532 }
(* 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 CDDL.Pulse open Pulse.Lib.Pervasives open Pulse.Lib.Stick open CBOR.Spec open CBOR.Pulse open CDDL.Spec module R = Pulse.Lib.Reference inline_for_extraction noextract [@@noextract_to "krml"] let impl_typ (#b: option raw_data_item) (t: bounded_typ_gen b) = (c: cbor) -> (#p: perm) -> (#v: Ghost.erased raw_data_item) -> stt bool (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b )) (fun res -> raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b /\ res == t v )) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_coerce_to_bounded_typ (b: Ghost.erased (option raw_data_item)) (#t: typ) (f: impl_typ t) : impl_typ #b (coerce_to_bounded_typ b t) // FIXME: WHY WHY WHY do I need to provide the implicit argument = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { f c; } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_choice (#b: Ghost.erased (option raw_data_item)) (#t1 #t2: bounded_typ_gen b) (f1: impl_typ t1) (f2: impl_typ t2) : impl_typ #b (t_choice t1 t2) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let test = f1 c; if (test) { true } else { f2 c } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_t_choice_none // FIXME: WHY WHY WHY can F* not automatically infer t1 and t2 by reducing (reveal (hide None)) to None? (#t1 #t2: bounded_typ_gen None) (f1: impl_typ t1) (f2: impl_typ t2) : Tot (impl_typ (t_choice t1 t2)) = impl_t_choice #None #t1 #t2 f1 f2 inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_any (_: unit) : impl_typ #None any = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { true } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint (_: unit) : impl_typ #None uint = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_uint64) } ``` module U64 = FStar.UInt64 (* FIXME: WHY WHY WHY does this one not work? inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal (n: U64.t) : impl_typ #None (t_uint_literal n) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; if (mt = major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` *) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal' (n: U64.t) (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) requires (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) )) returns res: bool ensures (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) /\ res == t_uint_literal n v )) { let mt = cbor_get_major_type c; if (mt = cbor_major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_uint_literal (n: U64.t) : impl_typ (t_uint_literal n) = impl_uint_literal' n inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_bytes (_: unit) : impl_typ #None bytes = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_byte_string) } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_array_group3 (#b: Ghost.erased (option raw_data_item)) (g: array_group3 b) = (pi: R.ref cbor_array_iterator_t) -> (#p: perm) -> (#i: Ghost.erased cbor_array_iterator_t) -> (#l: Ghost.erased (list raw_data_item)) -> stt bool (R.pts_to pi i ** cbor_array_iterator_match p i l ** pure (opt_precedes (Ghost.reveal l) b) ) (fun res -> exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ```pulse ghost fn intro_impl_array_group3_post (#b: option raw_data_item) (g: array_group3 b) (pi: R.ref cbor_array_iterator_t) (p: perm) (i: cbor_array_iterator_t) (l: list raw_data_item) (res: bool) (i': cbor_array_iterator_t) (l': list raw_data_item) requires ( R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ensures (exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) { () } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_concat (#b: Ghost.erased (option raw_data_item)) (#g1: array_group3 b) (f1: impl_array_group3 g1) (#g2: array_group3 b) (f2: impl_array_group3 g2) : impl_array_group3 #b (array_group3_concat g1 g2) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let test1 = f1 pi; if (test1) { let test2 = f2 pi; stick_trans (); test2 } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_item (#b: Ghost.erased (option raw_data_item)) (#ty: bounded_typ_gen b) (fty: impl_typ ty) : impl_array_group3 #b (array_group3_item ty) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let i = !pi; rewrite (cbor_array_iterator_match p gi l) as (cbor_array_iterator_match p i l); let is_done = cbor_array_iterator_is_done i; rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p gi l); if (is_done) { stick_refl0 (cbor_array_iterator_match p gi l); intro_impl_array_group3_post (array_group3_item ty) pi p gi l false gi l; // FIXME: WHY WHY WHY? and also WHY WHY WHY here and not in the other "false" case below? false } else { let c = cbor_array_iterator_next pi #p #l #gi; // FIXME: WHY WHY WHY those explicit arguments? with gc i' l' . assert ( raw_data_item_match p c gc ** cbor_array_iterator_match p i' l' ** ((raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') @==> cbor_array_iterator_match p gi l) ); // this is needed for the explicit arguments to split_consume_l below let test = fty c; if (test) { stick_consume_l () #(raw_data_item_match p c gc) #(cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l) // FIXME: WHY WHY WHY those explicit arguments? (for which the with above is needed) ; true } else { elim_stick0 () #(raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l); // FIXME: WHY WHY WHY those explicit arguments? pi := i; rewrite (R.pts_to pi i) as (R.pts_to pi gi); stick_refl0 (cbor_array_iterator_match p gi l); false } } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_array (#b: Ghost.erased (option raw_data_item)) (#g: (array_group3 b)) (ig: (impl_array_group3 (g))) : impl_typ #b (t_array3 g) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let ty = cbor_get_major_type c; if (ty = cbor_major_type_array) { let i = cbor_array_iterator_init c; with l . assert (cbor_array_iterator_match p i l); rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l); let mut pi = i; let b_success = ig pi; with gi' l' . assert (cbor_array_iterator_match p gi' l'); let i' = ! pi; rewrite (cbor_array_iterator_match p gi' l') as (cbor_array_iterator_match p i' l'); let b_end = cbor_array_iterator_is_done i'; rewrite (cbor_array_iterator_match p i' l') as (cbor_array_iterator_match p gi' l'); elim_stick0 (); rewrite (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l) as (cbor_array_iterator_match p i l); elim_stick0 (); (b_success && b_end) } else { false } } ``` module U8 = FStar.UInt8 noextract [@@noextract_to "krml"] let cbor_read_with_typ_success_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Tot prop = cbor_read_success_postcond va c v rem /\ t v == true module A = Pulse.Lib.Array let cbor_read_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) : Tot vprop = exists* v rem. raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem ** ((raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem) @==> A.pts_to a #p va) ** pure (cbor_read_with_typ_success_postcond t va c v rem) noextract [@@noextract_to "krml"] let cbor_read_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop = forall v suff . Ghost.reveal va == serialize_cbor v `Seq.append` suff ==> t v == false let cbor_read_with_typ_error_postcond_intro_typ_fail (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Lemma (requires ( cbor_read_success_postcond va c v rem /\ t v == false )) (ensures ( cbor_read_with_typ_error_postcond t va )) = serialize_cbor_with_test_correct v rem (fun v' rem' -> t v' == true) let cbor_read_with_typ_error_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) : Tot vprop = A.pts_to a #p va ** pure (cbor_read_with_typ_error_postcond t va) let cbor_read_with_typ_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop = if res.cbor_read_is_success then cbor_read_with_typ_success_post t a p va res else cbor_read_with_typ_error_post t a p va module SZ = FStar.SizeT inline_for_extraction noextract let mk_cbor_read_error (res: cbor_read_t) : Tot cbor_read_t = {res with cbor_read_is_success = false} inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn cbor_read_with_typ (#t: typ) (ft: impl_typ t) (a: A.array U8.t) (sz: SZ.t) (#va: Ghost.erased (Seq.seq U8.t)) (#p: perm) requires (A.pts_to a #p va ** pure ( (SZ.v sz == Seq.length va \/ SZ.v sz == A.length a) )) returns res: cbor_read_t ensures cbor_read_with_typ_post t a p va res { let res = cbor_read a sz; if (res.cbor_read_is_success) { rewrite (cbor_read_post a p va res) as (cbor_read_success_post a p va res); unfold (cbor_read_success_post a p va res); let test = ft res.cbor_read_payload; if (test) { fold (cbor_read_with_typ_success_post t a p va res); rewrite (cbor_read_with_typ_success_post t a p va res) as (cbor_read_with_typ_post t a p va res); res } else { with v . assert (raw_data_item_match full_perm res.cbor_read_payload v); with vrem . assert (A.pts_to res.cbor_read_remainder #p vrem); cbor_read_with_typ_error_postcond_intro_typ_fail t va res v vrem; elim_stick0 () #(raw_data_item_match full_perm res.cbor_read_payload v ** A.pts_to res.cbor_read_remainder #p vrem); fold (cbor_read_with_typ_error_post t a p va); let res = mk_cbor_read_error res; rewrite (cbor_read_with_typ_error_post t a p va) as (cbor_read_with_typ_post t a p va res); res } } else { rewrite (cbor_read_post a p va res) as (cbor_read_error_post a p va); unfold (cbor_read_error_post a p va); fold (cbor_read_with_typ_error_post t a p va); rewrite (cbor_read_with_typ_error_post t a p va) as (cbor_read_with_typ_post t a p va res); res } } ``` noextract [@@noextract_to "krml"] let cbor_read_deterministically_encoded_with_typ_success_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Tot prop = cbor_read_deterministically_encoded_success_postcond va c v rem /\ t v == true noextract [@@noextract_to "krml"] let cbor_read_deterministically_encoded_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop = forall v suff . (Ghost.reveal va == serialize_cbor v `Seq.append` suff /\ data_item_wf deterministically_encoded_cbor_map_key_order v == true ) ==> t v == false let cbor_read_deterministically_encoded_with_typ_error_postcond_intro_typ_fail (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Lemma (requires ( cbor_read_deterministically_encoded_success_postcond va c v rem /\ t v == false )) (ensures ( cbor_read_deterministically_encoded_with_typ_error_postcond t va )) = serialize_cbor_with_test_correct v rem (fun v' rem' -> data_item_wf deterministically_encoded_cbor_map_key_order v' == true /\ t v' == true)
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Stick.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CDDL.Spec.fsti.checked", "CBOR.Spec.fsti.checked", "CBOR.Pulse.fst.checked" ], "interface_file": false, "source_file": "CDDL.Pulse.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "CDDL.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Pulse", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Stick", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: CDDL.Spec.typ -> a: Pulse.Lib.Array.Core.array FStar.UInt8.t -> p: PulseCore.FractionalPermission.perm -> va: FStar.Ghost.erased (FStar.Seq.Base.seq FStar.UInt8.t) -> res: CBOR.Pulse.Extern.cbor_read_t -> Pulse.Lib.Core.vprop
Prims.Tot
[ "total" ]
[]
[ "CDDL.Spec.typ", "Pulse.Lib.Array.Core.array", "FStar.UInt8.t", "PulseCore.FractionalPermission.perm", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "CBOR.Pulse.Extern.cbor_read_t", "Pulse.Lib.Core.op_exists_Star", "CBOR.Spec.Type.raw_data_item", "Pulse.Lib.Core.op_Star_Star", "CBOR.Pulse.Extern.raw_data_item_match", "PulseCore.FractionalPermission.full_perm", "CBOR.Pulse.Extern.__proj__Mkcbor_read_t__item__cbor_read_payload", "Pulse.Lib.Array.Core.pts_to", "CBOR.Pulse.Extern.__proj__Mkcbor_read_t__item__cbor_read_remainder", "Pulse.Lib.Stick.op_At_Equals_Equals_Greater", "FStar.Ghost.reveal", "Pulse.Lib.Core.pure", "CDDL.Pulse.cbor_read_deterministically_encoded_with_typ_success_postcond", "Pulse.Lib.Core.vprop" ]
[]
false
false
false
true
false
let cbor_read_deterministically_encoded_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop =
exists* v rem. ((raw_data_item_match full_perm res.cbor_read_payload v ** A.pts_to res.cbor_read_remainder #p rem) ** ((raw_data_item_match full_perm res.cbor_read_payload v ** A.pts_to res.cbor_read_remainder #p rem ) @==> A.pts_to a #p va)) ** pure (cbor_read_deterministically_encoded_with_typ_success_postcond t va res v rem)
false
CDDL.Pulse.fst
CDDL.Pulse.mk_cbor_read_error
val mk_cbor_read_error (res: cbor_read_t) : Tot cbor_read_t
val mk_cbor_read_error (res: cbor_read_t) : Tot cbor_read_t
let mk_cbor_read_error (res: cbor_read_t) : Tot cbor_read_t = {res with cbor_read_is_success = false}
{ "file_name": "share/steel/examples/pulse/dice/cbor/CDDL.Pulse.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 41, "end_line": 446, "start_col": 0, "start_line": 443 }
(* 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 CDDL.Pulse open Pulse.Lib.Pervasives open Pulse.Lib.Stick open CBOR.Spec open CBOR.Pulse open CDDL.Spec module R = Pulse.Lib.Reference inline_for_extraction noextract [@@noextract_to "krml"] let impl_typ (#b: option raw_data_item) (t: bounded_typ_gen b) = (c: cbor) -> (#p: perm) -> (#v: Ghost.erased raw_data_item) -> stt bool (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b )) (fun res -> raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b /\ res == t v )) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_coerce_to_bounded_typ (b: Ghost.erased (option raw_data_item)) (#t: typ) (f: impl_typ t) : impl_typ #b (coerce_to_bounded_typ b t) // FIXME: WHY WHY WHY do I need to provide the implicit argument = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { f c; } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_choice (#b: Ghost.erased (option raw_data_item)) (#t1 #t2: bounded_typ_gen b) (f1: impl_typ t1) (f2: impl_typ t2) : impl_typ #b (t_choice t1 t2) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let test = f1 c; if (test) { true } else { f2 c } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_t_choice_none // FIXME: WHY WHY WHY can F* not automatically infer t1 and t2 by reducing (reveal (hide None)) to None? (#t1 #t2: bounded_typ_gen None) (f1: impl_typ t1) (f2: impl_typ t2) : Tot (impl_typ (t_choice t1 t2)) = impl_t_choice #None #t1 #t2 f1 f2 inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_any (_: unit) : impl_typ #None any = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { true } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint (_: unit) : impl_typ #None uint = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_uint64) } ``` module U64 = FStar.UInt64 (* FIXME: WHY WHY WHY does this one not work? inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal (n: U64.t) : impl_typ #None (t_uint_literal n) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; if (mt = major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` *) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal' (n: U64.t) (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) requires (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) )) returns res: bool ensures (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) /\ res == t_uint_literal n v )) { let mt = cbor_get_major_type c; if (mt = cbor_major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_uint_literal (n: U64.t) : impl_typ (t_uint_literal n) = impl_uint_literal' n inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_bytes (_: unit) : impl_typ #None bytes = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_byte_string) } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_array_group3 (#b: Ghost.erased (option raw_data_item)) (g: array_group3 b) = (pi: R.ref cbor_array_iterator_t) -> (#p: perm) -> (#i: Ghost.erased cbor_array_iterator_t) -> (#l: Ghost.erased (list raw_data_item)) -> stt bool (R.pts_to pi i ** cbor_array_iterator_match p i l ** pure (opt_precedes (Ghost.reveal l) b) ) (fun res -> exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ```pulse ghost fn intro_impl_array_group3_post (#b: option raw_data_item) (g: array_group3 b) (pi: R.ref cbor_array_iterator_t) (p: perm) (i: cbor_array_iterator_t) (l: list raw_data_item) (res: bool) (i': cbor_array_iterator_t) (l': list raw_data_item) requires ( R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ensures (exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) { () } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_concat (#b: Ghost.erased (option raw_data_item)) (#g1: array_group3 b) (f1: impl_array_group3 g1) (#g2: array_group3 b) (f2: impl_array_group3 g2) : impl_array_group3 #b (array_group3_concat g1 g2) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let test1 = f1 pi; if (test1) { let test2 = f2 pi; stick_trans (); test2 } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_item (#b: Ghost.erased (option raw_data_item)) (#ty: bounded_typ_gen b) (fty: impl_typ ty) : impl_array_group3 #b (array_group3_item ty) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let i = !pi; rewrite (cbor_array_iterator_match p gi l) as (cbor_array_iterator_match p i l); let is_done = cbor_array_iterator_is_done i; rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p gi l); if (is_done) { stick_refl0 (cbor_array_iterator_match p gi l); intro_impl_array_group3_post (array_group3_item ty) pi p gi l false gi l; // FIXME: WHY WHY WHY? and also WHY WHY WHY here and not in the other "false" case below? false } else { let c = cbor_array_iterator_next pi #p #l #gi; // FIXME: WHY WHY WHY those explicit arguments? with gc i' l' . assert ( raw_data_item_match p c gc ** cbor_array_iterator_match p i' l' ** ((raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') @==> cbor_array_iterator_match p gi l) ); // this is needed for the explicit arguments to split_consume_l below let test = fty c; if (test) { stick_consume_l () #(raw_data_item_match p c gc) #(cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l) // FIXME: WHY WHY WHY those explicit arguments? (for which the with above is needed) ; true } else { elim_stick0 () #(raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l); // FIXME: WHY WHY WHY those explicit arguments? pi := i; rewrite (R.pts_to pi i) as (R.pts_to pi gi); stick_refl0 (cbor_array_iterator_match p gi l); false } } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_array (#b: Ghost.erased (option raw_data_item)) (#g: (array_group3 b)) (ig: (impl_array_group3 (g))) : impl_typ #b (t_array3 g) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let ty = cbor_get_major_type c; if (ty = cbor_major_type_array) { let i = cbor_array_iterator_init c; with l . assert (cbor_array_iterator_match p i l); rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l); let mut pi = i; let b_success = ig pi; with gi' l' . assert (cbor_array_iterator_match p gi' l'); let i' = ! pi; rewrite (cbor_array_iterator_match p gi' l') as (cbor_array_iterator_match p i' l'); let b_end = cbor_array_iterator_is_done i'; rewrite (cbor_array_iterator_match p i' l') as (cbor_array_iterator_match p gi' l'); elim_stick0 (); rewrite (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l) as (cbor_array_iterator_match p i l); elim_stick0 (); (b_success && b_end) } else { false } } ``` module U8 = FStar.UInt8 noextract [@@noextract_to "krml"] let cbor_read_with_typ_success_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Tot prop = cbor_read_success_postcond va c v rem /\ t v == true module A = Pulse.Lib.Array let cbor_read_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) : Tot vprop = exists* v rem. raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem ** ((raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem) @==> A.pts_to a #p va) ** pure (cbor_read_with_typ_success_postcond t va c v rem) noextract [@@noextract_to "krml"] let cbor_read_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop = forall v suff . Ghost.reveal va == serialize_cbor v `Seq.append` suff ==> t v == false let cbor_read_with_typ_error_postcond_intro_typ_fail (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Lemma (requires ( cbor_read_success_postcond va c v rem /\ t v == false )) (ensures ( cbor_read_with_typ_error_postcond t va )) = serialize_cbor_with_test_correct v rem (fun v' rem' -> t v' == true) let cbor_read_with_typ_error_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) : Tot vprop = A.pts_to a #p va ** pure (cbor_read_with_typ_error_postcond t va) let cbor_read_with_typ_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop = if res.cbor_read_is_success then cbor_read_with_typ_success_post t a p va res else cbor_read_with_typ_error_post t a p va module SZ = FStar.SizeT
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Stick.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CDDL.Spec.fsti.checked", "CBOR.Spec.fsti.checked", "CBOR.Pulse.fst.checked" ], "interface_file": false, "source_file": "CDDL.Pulse.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "CDDL.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Pulse", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Stick", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
res: CBOR.Pulse.Extern.cbor_read_t -> CBOR.Pulse.Extern.cbor_read_t
Prims.Tot
[ "total" ]
[]
[ "CBOR.Pulse.Extern.cbor_read_t", "CBOR.Pulse.Extern.Mkcbor_read_t", "CBOR.Pulse.Extern.__proj__Mkcbor_read_t__item__cbor_read_payload", "CBOR.Pulse.Extern.__proj__Mkcbor_read_t__item__cbor_read_remainder", "CBOR.Pulse.Extern.__proj__Mkcbor_read_t__item__cbor_read_remainder_length" ]
[]
false
false
false
true
false
let mk_cbor_read_error (res: cbor_read_t) : Tot cbor_read_t =
{ res with cbor_read_is_success = false }
false
CDDL.Pulse.fst
CDDL.Pulse.cbor_read_deterministically_encoded_with_typ_error_postcond
val cbor_read_deterministically_encoded_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop
val cbor_read_deterministically_encoded_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop
let cbor_read_deterministically_encoded_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop = forall v suff . (Ghost.reveal va == serialize_cbor v `Seq.append` suff /\ data_item_wf deterministically_encoded_cbor_map_key_order v == true ) ==> t v == false
{ "file_name": "share/steel/examples/pulse/dice/cbor/CDDL.Pulse.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 16, "end_line": 514, "start_col": 0, "start_line": 506 }
(* 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 CDDL.Pulse open Pulse.Lib.Pervasives open Pulse.Lib.Stick open CBOR.Spec open CBOR.Pulse open CDDL.Spec module R = Pulse.Lib.Reference inline_for_extraction noextract [@@noextract_to "krml"] let impl_typ (#b: option raw_data_item) (t: bounded_typ_gen b) = (c: cbor) -> (#p: perm) -> (#v: Ghost.erased raw_data_item) -> stt bool (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b )) (fun res -> raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b /\ res == t v )) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_coerce_to_bounded_typ (b: Ghost.erased (option raw_data_item)) (#t: typ) (f: impl_typ t) : impl_typ #b (coerce_to_bounded_typ b t) // FIXME: WHY WHY WHY do I need to provide the implicit argument = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { f c; } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_choice (#b: Ghost.erased (option raw_data_item)) (#t1 #t2: bounded_typ_gen b) (f1: impl_typ t1) (f2: impl_typ t2) : impl_typ #b (t_choice t1 t2) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let test = f1 c; if (test) { true } else { f2 c } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_t_choice_none // FIXME: WHY WHY WHY can F* not automatically infer t1 and t2 by reducing (reveal (hide None)) to None? (#t1 #t2: bounded_typ_gen None) (f1: impl_typ t1) (f2: impl_typ t2) : Tot (impl_typ (t_choice t1 t2)) = impl_t_choice #None #t1 #t2 f1 f2 inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_any (_: unit) : impl_typ #None any = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { true } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint (_: unit) : impl_typ #None uint = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_uint64) } ``` module U64 = FStar.UInt64 (* FIXME: WHY WHY WHY does this one not work? inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal (n: U64.t) : impl_typ #None (t_uint_literal n) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; if (mt = major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` *) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal' (n: U64.t) (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) requires (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) )) returns res: bool ensures (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) /\ res == t_uint_literal n v )) { let mt = cbor_get_major_type c; if (mt = cbor_major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_uint_literal (n: U64.t) : impl_typ (t_uint_literal n) = impl_uint_literal' n inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_bytes (_: unit) : impl_typ #None bytes = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_byte_string) } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_array_group3 (#b: Ghost.erased (option raw_data_item)) (g: array_group3 b) = (pi: R.ref cbor_array_iterator_t) -> (#p: perm) -> (#i: Ghost.erased cbor_array_iterator_t) -> (#l: Ghost.erased (list raw_data_item)) -> stt bool (R.pts_to pi i ** cbor_array_iterator_match p i l ** pure (opt_precedes (Ghost.reveal l) b) ) (fun res -> exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ```pulse ghost fn intro_impl_array_group3_post (#b: option raw_data_item) (g: array_group3 b) (pi: R.ref cbor_array_iterator_t) (p: perm) (i: cbor_array_iterator_t) (l: list raw_data_item) (res: bool) (i': cbor_array_iterator_t) (l': list raw_data_item) requires ( R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ensures (exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) { () } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_concat (#b: Ghost.erased (option raw_data_item)) (#g1: array_group3 b) (f1: impl_array_group3 g1) (#g2: array_group3 b) (f2: impl_array_group3 g2) : impl_array_group3 #b (array_group3_concat g1 g2) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let test1 = f1 pi; if (test1) { let test2 = f2 pi; stick_trans (); test2 } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_item (#b: Ghost.erased (option raw_data_item)) (#ty: bounded_typ_gen b) (fty: impl_typ ty) : impl_array_group3 #b (array_group3_item ty) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let i = !pi; rewrite (cbor_array_iterator_match p gi l) as (cbor_array_iterator_match p i l); let is_done = cbor_array_iterator_is_done i; rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p gi l); if (is_done) { stick_refl0 (cbor_array_iterator_match p gi l); intro_impl_array_group3_post (array_group3_item ty) pi p gi l false gi l; // FIXME: WHY WHY WHY? and also WHY WHY WHY here and not in the other "false" case below? false } else { let c = cbor_array_iterator_next pi #p #l #gi; // FIXME: WHY WHY WHY those explicit arguments? with gc i' l' . assert ( raw_data_item_match p c gc ** cbor_array_iterator_match p i' l' ** ((raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') @==> cbor_array_iterator_match p gi l) ); // this is needed for the explicit arguments to split_consume_l below let test = fty c; if (test) { stick_consume_l () #(raw_data_item_match p c gc) #(cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l) // FIXME: WHY WHY WHY those explicit arguments? (for which the with above is needed) ; true } else { elim_stick0 () #(raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l); // FIXME: WHY WHY WHY those explicit arguments? pi := i; rewrite (R.pts_to pi i) as (R.pts_to pi gi); stick_refl0 (cbor_array_iterator_match p gi l); false } } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_array (#b: Ghost.erased (option raw_data_item)) (#g: (array_group3 b)) (ig: (impl_array_group3 (g))) : impl_typ #b (t_array3 g) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let ty = cbor_get_major_type c; if (ty = cbor_major_type_array) { let i = cbor_array_iterator_init c; with l . assert (cbor_array_iterator_match p i l); rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l); let mut pi = i; let b_success = ig pi; with gi' l' . assert (cbor_array_iterator_match p gi' l'); let i' = ! pi; rewrite (cbor_array_iterator_match p gi' l') as (cbor_array_iterator_match p i' l'); let b_end = cbor_array_iterator_is_done i'; rewrite (cbor_array_iterator_match p i' l') as (cbor_array_iterator_match p gi' l'); elim_stick0 (); rewrite (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l) as (cbor_array_iterator_match p i l); elim_stick0 (); (b_success && b_end) } else { false } } ``` module U8 = FStar.UInt8 noextract [@@noextract_to "krml"] let cbor_read_with_typ_success_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Tot prop = cbor_read_success_postcond va c v rem /\ t v == true module A = Pulse.Lib.Array let cbor_read_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) : Tot vprop = exists* v rem. raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem ** ((raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem) @==> A.pts_to a #p va) ** pure (cbor_read_with_typ_success_postcond t va c v rem) noextract [@@noextract_to "krml"] let cbor_read_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop = forall v suff . Ghost.reveal va == serialize_cbor v `Seq.append` suff ==> t v == false let cbor_read_with_typ_error_postcond_intro_typ_fail (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Lemma (requires ( cbor_read_success_postcond va c v rem /\ t v == false )) (ensures ( cbor_read_with_typ_error_postcond t va )) = serialize_cbor_with_test_correct v rem (fun v' rem' -> t v' == true) let cbor_read_with_typ_error_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) : Tot vprop = A.pts_to a #p va ** pure (cbor_read_with_typ_error_postcond t va) let cbor_read_with_typ_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop = if res.cbor_read_is_success then cbor_read_with_typ_success_post t a p va res else cbor_read_with_typ_error_post t a p va module SZ = FStar.SizeT inline_for_extraction noextract let mk_cbor_read_error (res: cbor_read_t) : Tot cbor_read_t = {res with cbor_read_is_success = false} inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn cbor_read_with_typ (#t: typ) (ft: impl_typ t) (a: A.array U8.t) (sz: SZ.t) (#va: Ghost.erased (Seq.seq U8.t)) (#p: perm) requires (A.pts_to a #p va ** pure ( (SZ.v sz == Seq.length va \/ SZ.v sz == A.length a) )) returns res: cbor_read_t ensures cbor_read_with_typ_post t a p va res { let res = cbor_read a sz; if (res.cbor_read_is_success) { rewrite (cbor_read_post a p va res) as (cbor_read_success_post a p va res); unfold (cbor_read_success_post a p va res); let test = ft res.cbor_read_payload; if (test) { fold (cbor_read_with_typ_success_post t a p va res); rewrite (cbor_read_with_typ_success_post t a p va res) as (cbor_read_with_typ_post t a p va res); res } else { with v . assert (raw_data_item_match full_perm res.cbor_read_payload v); with vrem . assert (A.pts_to res.cbor_read_remainder #p vrem); cbor_read_with_typ_error_postcond_intro_typ_fail t va res v vrem; elim_stick0 () #(raw_data_item_match full_perm res.cbor_read_payload v ** A.pts_to res.cbor_read_remainder #p vrem); fold (cbor_read_with_typ_error_post t a p va); let res = mk_cbor_read_error res; rewrite (cbor_read_with_typ_error_post t a p va) as (cbor_read_with_typ_post t a p va res); res } } else { rewrite (cbor_read_post a p va res) as (cbor_read_error_post a p va); unfold (cbor_read_error_post a p va); fold (cbor_read_with_typ_error_post t a p va); rewrite (cbor_read_with_typ_error_post t a p va) as (cbor_read_with_typ_post t a p va res); res } } ``` noextract [@@noextract_to "krml"] let cbor_read_deterministically_encoded_with_typ_success_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Tot prop = cbor_read_deterministically_encoded_success_postcond va c v rem /\ t v == true
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Stick.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CDDL.Spec.fsti.checked", "CBOR.Spec.fsti.checked", "CBOR.Pulse.fst.checked" ], "interface_file": false, "source_file": "CDDL.Pulse.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "CDDL.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Pulse", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Stick", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: CDDL.Spec.typ -> va: FStar.Ghost.erased (FStar.Seq.Base.seq FStar.UInt8.t) -> Prims.prop
Prims.Tot
[ "total" ]
[]
[ "CDDL.Spec.typ", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "FStar.UInt8.t", "Prims.l_Forall", "CBOR.Spec.Type.raw_data_item", "CDDL.Spec.opt_precedes", "FStar.Pervasives.Native.None", "Prims.l_imp", "Prims.l_and", "Prims.eq2", "FStar.Ghost.reveal", "FStar.Seq.Base.append", "CBOR.Spec.serialize_cbor", "Prims.bool", "CBOR.Spec.Type.data_item_wf", "CBOR.Spec.deterministically_encoded_cbor_map_key_order", "Prims.prop" ]
[]
false
false
false
true
true
let cbor_read_deterministically_encoded_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop =
forall v suff. (Ghost.reveal va == (serialize_cbor v) `Seq.append` suff /\ data_item_wf deterministically_encoded_cbor_map_key_order v == true) ==> t v == false
false
Vale.X64.StateLemmas.fsti
Vale.X64.StateLemmas.state_to_S
val state_to_S (s: vale_state) : GTot machine_state
val state_to_S (s: vale_state) : GTot machine_state
let state_to_S (s:vale_state) : GTot machine_state = let open Ms in { ms_ok = s.vs_ok; ms_regs = Regs.to_fun s.vs_regs; ms_flags = Flags.to_fun s.vs_flags; ms_heap = coerce s.vs_heap; ms_stack = VSS.stack_to_s s.vs_stack; ms_stackTaint = s.vs_stackTaint; ms_trace = []; }
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 52, "start_col": 0, "start_line": 42 }
module Vale.X64.StateLemmas open Vale.X64.Machine_s open Vale.Arch.Heap open Vale.X64.State open FStar.FunctionalExtensionality module Ms = Vale.X64.Machine_Semantics_s //open Vale.X64.Machine_Semantics_s //module ME = Vale.X64.Memory open Vale.X64.Memory open Vale.Arch.MachineHeap_s //module MS = Vale.X64.Memory_Sems module VSS = Vale.X64.Stack_Sems module F = FStar.FunctionalExtensionality open Vale.Def.Prop_s open FStar.Mul unfold let machine_state = Ms.machine_state unfold let code = Ms.code unfold let machine_eval_code = Ms.machine_eval_code val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x let machine_state_eq (s1 s2:machine_state) = s1 == s2 let machine_state_equal (s1 s2:machine_state) = let open Vale.X64.Machine_Semantics_s in s1.ms_ok == s2.ms_ok /\ F.feq s1.ms_regs s2.ms_regs /\ F.feq s1.ms_flags s2.ms_flags /\ s1.ms_heap == s2.ms_heap /\ s1.ms_stack == s2.ms_stack /\ s1.ms_stackTaint == s2.ms_stackTaint /\ s1.ms_trace == s2.ms_trace /\ True val use_machine_state_equal (_:unit) : Lemma (requires True) (ensures forall (s1 s2:machine_state).{:pattern machine_state_eq s1 s2} machine_state_equal s1 s2 ==> machine_state_eq s1 s2)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Regs.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.StateLemmas.fsti" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.X64.Stack_i", "short_module": "VST" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.X64.Memory_Sems", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "Ms" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
s: Vale.X64.State.vale_state -> Prims.GTot Vale.X64.StateLemmas.machine_state
Prims.GTot
[ "sometrivial" ]
[]
[ "Vale.X64.State.vale_state", "Vale.X64.Machine_Semantics_s.Mkmachine_state", "Vale.X64.State.__proj__Mkvale_state__item__vs_ok", "Vale.X64.Regs.to_fun", "Vale.X64.State.__proj__Mkvale_state__item__vs_regs", "Vale.X64.Flags.to_fun", "Vale.X64.State.__proj__Mkvale_state__item__vs_flags", "Vale.X64.StateLemmas.coerce", "Vale.Arch.Heap.heap_impl", "Vale.X64.Memory.vale_full_heap", "Vale.X64.State.__proj__Mkvale_state__item__vs_heap", "Vale.X64.Stack_Sems.stack_to_s", "Vale.X64.State.__proj__Mkvale_state__item__vs_stack", "Vale.X64.State.__proj__Mkvale_state__item__vs_stackTaint", "Prims.Nil", "Vale.X64.Machine_s.observation", "Vale.X64.StateLemmas.machine_state" ]
[]
false
false
false
false
false
let state_to_S (s: vale_state) : GTot machine_state =
let open Ms in { ms_ok = s.vs_ok; ms_regs = Regs.to_fun s.vs_regs; ms_flags = Flags.to_fun s.vs_flags; ms_heap = coerce s.vs_heap; ms_stack = VSS.stack_to_s s.vs_stack; ms_stackTaint = s.vs_stackTaint; ms_trace = [] }
false
CDDL.Pulse.fst
CDDL.Pulse.cbor_read_with_typ_error_postcond
val cbor_read_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop
val cbor_read_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop
let cbor_read_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop = forall v suff . Ghost.reveal va == serialize_cbor v `Seq.append` suff ==> t v == false
{ "file_name": "share/steel/examples/pulse/dice/cbor/CDDL.Pulse.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 16, "end_line": 403, "start_col": 0, "start_line": 397 }
(* 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 CDDL.Pulse open Pulse.Lib.Pervasives open Pulse.Lib.Stick open CBOR.Spec open CBOR.Pulse open CDDL.Spec module R = Pulse.Lib.Reference inline_for_extraction noextract [@@noextract_to "krml"] let impl_typ (#b: option raw_data_item) (t: bounded_typ_gen b) = (c: cbor) -> (#p: perm) -> (#v: Ghost.erased raw_data_item) -> stt bool (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b )) (fun res -> raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b /\ res == t v )) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_coerce_to_bounded_typ (b: Ghost.erased (option raw_data_item)) (#t: typ) (f: impl_typ t) : impl_typ #b (coerce_to_bounded_typ b t) // FIXME: WHY WHY WHY do I need to provide the implicit argument = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { f c; } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_choice (#b: Ghost.erased (option raw_data_item)) (#t1 #t2: bounded_typ_gen b) (f1: impl_typ t1) (f2: impl_typ t2) : impl_typ #b (t_choice t1 t2) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let test = f1 c; if (test) { true } else { f2 c } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_t_choice_none // FIXME: WHY WHY WHY can F* not automatically infer t1 and t2 by reducing (reveal (hide None)) to None? (#t1 #t2: bounded_typ_gen None) (f1: impl_typ t1) (f2: impl_typ t2) : Tot (impl_typ (t_choice t1 t2)) = impl_t_choice #None #t1 #t2 f1 f2 inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_any (_: unit) : impl_typ #None any = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { true } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint (_: unit) : impl_typ #None uint = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_uint64) } ``` module U64 = FStar.UInt64 (* FIXME: WHY WHY WHY does this one not work? inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal (n: U64.t) : impl_typ #None (t_uint_literal n) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; if (mt = major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` *) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal' (n: U64.t) (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) requires (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) )) returns res: bool ensures (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) /\ res == t_uint_literal n v )) { let mt = cbor_get_major_type c; if (mt = cbor_major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_uint_literal (n: U64.t) : impl_typ (t_uint_literal n) = impl_uint_literal' n inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_bytes (_: unit) : impl_typ #None bytes = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_byte_string) } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_array_group3 (#b: Ghost.erased (option raw_data_item)) (g: array_group3 b) = (pi: R.ref cbor_array_iterator_t) -> (#p: perm) -> (#i: Ghost.erased cbor_array_iterator_t) -> (#l: Ghost.erased (list raw_data_item)) -> stt bool (R.pts_to pi i ** cbor_array_iterator_match p i l ** pure (opt_precedes (Ghost.reveal l) b) ) (fun res -> exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ```pulse ghost fn intro_impl_array_group3_post (#b: option raw_data_item) (g: array_group3 b) (pi: R.ref cbor_array_iterator_t) (p: perm) (i: cbor_array_iterator_t) (l: list raw_data_item) (res: bool) (i': cbor_array_iterator_t) (l': list raw_data_item) requires ( R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ensures (exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) { () } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_concat (#b: Ghost.erased (option raw_data_item)) (#g1: array_group3 b) (f1: impl_array_group3 g1) (#g2: array_group3 b) (f2: impl_array_group3 g2) : impl_array_group3 #b (array_group3_concat g1 g2) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let test1 = f1 pi; if (test1) { let test2 = f2 pi; stick_trans (); test2 } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_item (#b: Ghost.erased (option raw_data_item)) (#ty: bounded_typ_gen b) (fty: impl_typ ty) : impl_array_group3 #b (array_group3_item ty) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let i = !pi; rewrite (cbor_array_iterator_match p gi l) as (cbor_array_iterator_match p i l); let is_done = cbor_array_iterator_is_done i; rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p gi l); if (is_done) { stick_refl0 (cbor_array_iterator_match p gi l); intro_impl_array_group3_post (array_group3_item ty) pi p gi l false gi l; // FIXME: WHY WHY WHY? and also WHY WHY WHY here and not in the other "false" case below? false } else { let c = cbor_array_iterator_next pi #p #l #gi; // FIXME: WHY WHY WHY those explicit arguments? with gc i' l' . assert ( raw_data_item_match p c gc ** cbor_array_iterator_match p i' l' ** ((raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') @==> cbor_array_iterator_match p gi l) ); // this is needed for the explicit arguments to split_consume_l below let test = fty c; if (test) { stick_consume_l () #(raw_data_item_match p c gc) #(cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l) // FIXME: WHY WHY WHY those explicit arguments? (for which the with above is needed) ; true } else { elim_stick0 () #(raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l); // FIXME: WHY WHY WHY those explicit arguments? pi := i; rewrite (R.pts_to pi i) as (R.pts_to pi gi); stick_refl0 (cbor_array_iterator_match p gi l); false } } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_array (#b: Ghost.erased (option raw_data_item)) (#g: (array_group3 b)) (ig: (impl_array_group3 (g))) : impl_typ #b (t_array3 g) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let ty = cbor_get_major_type c; if (ty = cbor_major_type_array) { let i = cbor_array_iterator_init c; with l . assert (cbor_array_iterator_match p i l); rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l); let mut pi = i; let b_success = ig pi; with gi' l' . assert (cbor_array_iterator_match p gi' l'); let i' = ! pi; rewrite (cbor_array_iterator_match p gi' l') as (cbor_array_iterator_match p i' l'); let b_end = cbor_array_iterator_is_done i'; rewrite (cbor_array_iterator_match p i' l') as (cbor_array_iterator_match p gi' l'); elim_stick0 (); rewrite (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l) as (cbor_array_iterator_match p i l); elim_stick0 (); (b_success && b_end) } else { false } } ``` module U8 = FStar.UInt8 noextract [@@noextract_to "krml"] let cbor_read_with_typ_success_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Tot prop = cbor_read_success_postcond va c v rem /\ t v == true module A = Pulse.Lib.Array let cbor_read_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) : Tot vprop = exists* v rem. raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem ** ((raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem) @==> A.pts_to a #p va) ** pure (cbor_read_with_typ_success_postcond t va c v rem)
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Stick.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CDDL.Spec.fsti.checked", "CBOR.Spec.fsti.checked", "CBOR.Pulse.fst.checked" ], "interface_file": false, "source_file": "CDDL.Pulse.fst" }
[ { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "CDDL.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Pulse", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Stick", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: CDDL.Spec.typ -> va: FStar.Ghost.erased (FStar.Seq.Base.seq FStar.UInt8.t) -> Prims.prop
Prims.Tot
[ "total" ]
[]
[ "CDDL.Spec.typ", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "FStar.UInt8.t", "Prims.l_Forall", "CBOR.Spec.Type.raw_data_item", "CDDL.Spec.opt_precedes", "FStar.Pervasives.Native.None", "Prims.l_imp", "Prims.eq2", "FStar.Ghost.reveal", "FStar.Seq.Base.append", "CBOR.Spec.serialize_cbor", "Prims.bool", "Prims.prop" ]
[]
false
false
false
true
true
let cbor_read_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop =
forall v suff. Ghost.reveal va == (serialize_cbor v) `Seq.append` suff ==> t v == false
false
CDDL.Pulse.fst
CDDL.Pulse.cbor_read_deterministically_encoded_with_typ_error_post
val cbor_read_deterministically_encoded_with_typ_error_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) : Tot vprop
val cbor_read_deterministically_encoded_with_typ_error_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) : Tot vprop
let cbor_read_deterministically_encoded_with_typ_error_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) : Tot vprop = A.pts_to a #p va ** pure (cbor_read_deterministically_encoded_with_typ_error_postcond t va)
{ "file_name": "share/steel/examples/pulse/dice/cbor/CDDL.Pulse.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 93, "end_line": 552, "start_col": 0, "start_line": 546 }
(* 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 CDDL.Pulse open Pulse.Lib.Pervasives open Pulse.Lib.Stick open CBOR.Spec open CBOR.Pulse open CDDL.Spec module R = Pulse.Lib.Reference inline_for_extraction noextract [@@noextract_to "krml"] let impl_typ (#b: option raw_data_item) (t: bounded_typ_gen b) = (c: cbor) -> (#p: perm) -> (#v: Ghost.erased raw_data_item) -> stt bool (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b )) (fun res -> raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b /\ res == t v )) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_coerce_to_bounded_typ (b: Ghost.erased (option raw_data_item)) (#t: typ) (f: impl_typ t) : impl_typ #b (coerce_to_bounded_typ b t) // FIXME: WHY WHY WHY do I need to provide the implicit argument = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { f c; } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_choice (#b: Ghost.erased (option raw_data_item)) (#t1 #t2: bounded_typ_gen b) (f1: impl_typ t1) (f2: impl_typ t2) : impl_typ #b (t_choice t1 t2) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let test = f1 c; if (test) { true } else { f2 c } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_t_choice_none // FIXME: WHY WHY WHY can F* not automatically infer t1 and t2 by reducing (reveal (hide None)) to None? (#t1 #t2: bounded_typ_gen None) (f1: impl_typ t1) (f2: impl_typ t2) : Tot (impl_typ (t_choice t1 t2)) = impl_t_choice #None #t1 #t2 f1 f2 inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_any (_: unit) : impl_typ #None any = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { true } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint (_: unit) : impl_typ #None uint = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_uint64) } ``` module U64 = FStar.UInt64 (* FIXME: WHY WHY WHY does this one not work? inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal (n: U64.t) : impl_typ #None (t_uint_literal n) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; if (mt = major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` *) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal' (n: U64.t) (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) requires (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) )) returns res: bool ensures (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) /\ res == t_uint_literal n v )) { let mt = cbor_get_major_type c; if (mt = cbor_major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_uint_literal (n: U64.t) : impl_typ (t_uint_literal n) = impl_uint_literal' n inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_bytes (_: unit) : impl_typ #None bytes = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_byte_string) } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_array_group3 (#b: Ghost.erased (option raw_data_item)) (g: array_group3 b) = (pi: R.ref cbor_array_iterator_t) -> (#p: perm) -> (#i: Ghost.erased cbor_array_iterator_t) -> (#l: Ghost.erased (list raw_data_item)) -> stt bool (R.pts_to pi i ** cbor_array_iterator_match p i l ** pure (opt_precedes (Ghost.reveal l) b) ) (fun res -> exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ```pulse ghost fn intro_impl_array_group3_post (#b: option raw_data_item) (g: array_group3 b) (pi: R.ref cbor_array_iterator_t) (p: perm) (i: cbor_array_iterator_t) (l: list raw_data_item) (res: bool) (i': cbor_array_iterator_t) (l': list raw_data_item) requires ( R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ensures (exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) { () } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_concat (#b: Ghost.erased (option raw_data_item)) (#g1: array_group3 b) (f1: impl_array_group3 g1) (#g2: array_group3 b) (f2: impl_array_group3 g2) : impl_array_group3 #b (array_group3_concat g1 g2) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let test1 = f1 pi; if (test1) { let test2 = f2 pi; stick_trans (); test2 } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_item (#b: Ghost.erased (option raw_data_item)) (#ty: bounded_typ_gen b) (fty: impl_typ ty) : impl_array_group3 #b (array_group3_item ty) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let i = !pi; rewrite (cbor_array_iterator_match p gi l) as (cbor_array_iterator_match p i l); let is_done = cbor_array_iterator_is_done i; rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p gi l); if (is_done) { stick_refl0 (cbor_array_iterator_match p gi l); intro_impl_array_group3_post (array_group3_item ty) pi p gi l false gi l; // FIXME: WHY WHY WHY? and also WHY WHY WHY here and not in the other "false" case below? false } else { let c = cbor_array_iterator_next pi #p #l #gi; // FIXME: WHY WHY WHY those explicit arguments? with gc i' l' . assert ( raw_data_item_match p c gc ** cbor_array_iterator_match p i' l' ** ((raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') @==> cbor_array_iterator_match p gi l) ); // this is needed for the explicit arguments to split_consume_l below let test = fty c; if (test) { stick_consume_l () #(raw_data_item_match p c gc) #(cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l) // FIXME: WHY WHY WHY those explicit arguments? (for which the with above is needed) ; true } else { elim_stick0 () #(raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l); // FIXME: WHY WHY WHY those explicit arguments? pi := i; rewrite (R.pts_to pi i) as (R.pts_to pi gi); stick_refl0 (cbor_array_iterator_match p gi l); false } } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_array (#b: Ghost.erased (option raw_data_item)) (#g: (array_group3 b)) (ig: (impl_array_group3 (g))) : impl_typ #b (t_array3 g) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let ty = cbor_get_major_type c; if (ty = cbor_major_type_array) { let i = cbor_array_iterator_init c; with l . assert (cbor_array_iterator_match p i l); rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l); let mut pi = i; let b_success = ig pi; with gi' l' . assert (cbor_array_iterator_match p gi' l'); let i' = ! pi; rewrite (cbor_array_iterator_match p gi' l') as (cbor_array_iterator_match p i' l'); let b_end = cbor_array_iterator_is_done i'; rewrite (cbor_array_iterator_match p i' l') as (cbor_array_iterator_match p gi' l'); elim_stick0 (); rewrite (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l) as (cbor_array_iterator_match p i l); elim_stick0 (); (b_success && b_end) } else { false } } ``` module U8 = FStar.UInt8 noextract [@@noextract_to "krml"] let cbor_read_with_typ_success_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Tot prop = cbor_read_success_postcond va c v rem /\ t v == true module A = Pulse.Lib.Array let cbor_read_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) : Tot vprop = exists* v rem. raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem ** ((raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem) @==> A.pts_to a #p va) ** pure (cbor_read_with_typ_success_postcond t va c v rem) noextract [@@noextract_to "krml"] let cbor_read_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop = forall v suff . Ghost.reveal va == serialize_cbor v `Seq.append` suff ==> t v == false let cbor_read_with_typ_error_postcond_intro_typ_fail (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Lemma (requires ( cbor_read_success_postcond va c v rem /\ t v == false )) (ensures ( cbor_read_with_typ_error_postcond t va )) = serialize_cbor_with_test_correct v rem (fun v' rem' -> t v' == true) let cbor_read_with_typ_error_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) : Tot vprop = A.pts_to a #p va ** pure (cbor_read_with_typ_error_postcond t va) let cbor_read_with_typ_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop = if res.cbor_read_is_success then cbor_read_with_typ_success_post t a p va res else cbor_read_with_typ_error_post t a p va module SZ = FStar.SizeT inline_for_extraction noextract let mk_cbor_read_error (res: cbor_read_t) : Tot cbor_read_t = {res with cbor_read_is_success = false} inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn cbor_read_with_typ (#t: typ) (ft: impl_typ t) (a: A.array U8.t) (sz: SZ.t) (#va: Ghost.erased (Seq.seq U8.t)) (#p: perm) requires (A.pts_to a #p va ** pure ( (SZ.v sz == Seq.length va \/ SZ.v sz == A.length a) )) returns res: cbor_read_t ensures cbor_read_with_typ_post t a p va res { let res = cbor_read a sz; if (res.cbor_read_is_success) { rewrite (cbor_read_post a p va res) as (cbor_read_success_post a p va res); unfold (cbor_read_success_post a p va res); let test = ft res.cbor_read_payload; if (test) { fold (cbor_read_with_typ_success_post t a p va res); rewrite (cbor_read_with_typ_success_post t a p va res) as (cbor_read_with_typ_post t a p va res); res } else { with v . assert (raw_data_item_match full_perm res.cbor_read_payload v); with vrem . assert (A.pts_to res.cbor_read_remainder #p vrem); cbor_read_with_typ_error_postcond_intro_typ_fail t va res v vrem; elim_stick0 () #(raw_data_item_match full_perm res.cbor_read_payload v ** A.pts_to res.cbor_read_remainder #p vrem); fold (cbor_read_with_typ_error_post t a p va); let res = mk_cbor_read_error res; rewrite (cbor_read_with_typ_error_post t a p va) as (cbor_read_with_typ_post t a p va res); res } } else { rewrite (cbor_read_post a p va res) as (cbor_read_error_post a p va); unfold (cbor_read_error_post a p va); fold (cbor_read_with_typ_error_post t a p va); rewrite (cbor_read_with_typ_error_post t a p va) as (cbor_read_with_typ_post t a p va res); res } } ``` noextract [@@noextract_to "krml"] let cbor_read_deterministically_encoded_with_typ_success_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Tot prop = cbor_read_deterministically_encoded_success_postcond va c v rem /\ t v == true noextract [@@noextract_to "krml"] let cbor_read_deterministically_encoded_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop = forall v suff . (Ghost.reveal va == serialize_cbor v `Seq.append` suff /\ data_item_wf deterministically_encoded_cbor_map_key_order v == true ) ==> t v == false let cbor_read_deterministically_encoded_with_typ_error_postcond_intro_typ_fail (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Lemma (requires ( cbor_read_deterministically_encoded_success_postcond va c v rem /\ t v == false )) (ensures ( cbor_read_deterministically_encoded_with_typ_error_postcond t va )) = serialize_cbor_with_test_correct v rem (fun v' rem' -> data_item_wf deterministically_encoded_cbor_map_key_order v' == true /\ t v' == true) let cbor_read_deterministically_encoded_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop = exists* v rem. raw_data_item_match full_perm res.cbor_read_payload v ** A.pts_to res.cbor_read_remainder #p rem ** ((raw_data_item_match full_perm res.cbor_read_payload v ** A.pts_to res.cbor_read_remainder #p rem) @==> A.pts_to a #p va) ** pure (cbor_read_deterministically_encoded_with_typ_success_postcond t va res v rem)
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Stick.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CDDL.Spec.fsti.checked", "CBOR.Spec.fsti.checked", "CBOR.Pulse.fst.checked" ], "interface_file": false, "source_file": "CDDL.Pulse.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "CDDL.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Pulse", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Stick", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: CDDL.Spec.typ -> a: Pulse.Lib.Array.Core.array FStar.UInt8.t -> p: PulseCore.FractionalPermission.perm -> va: FStar.Ghost.erased (FStar.Seq.Base.seq FStar.UInt8.t) -> Pulse.Lib.Core.vprop
Prims.Tot
[ "total" ]
[]
[ "CDDL.Spec.typ", "Pulse.Lib.Array.Core.array", "FStar.UInt8.t", "PulseCore.FractionalPermission.perm", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Pulse.Lib.Core.op_Star_Star", "Pulse.Lib.Array.Core.pts_to", "FStar.Ghost.reveal", "Pulse.Lib.Core.pure", "CDDL.Pulse.cbor_read_deterministically_encoded_with_typ_error_postcond", "Pulse.Lib.Core.vprop" ]
[]
false
false
false
true
false
let cbor_read_deterministically_encoded_with_typ_error_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) : Tot vprop =
A.pts_to a #p va ** pure (cbor_read_deterministically_encoded_with_typ_error_postcond t va)
false
Vale.X64.StateLemmas.fsti
Vale.X64.StateLemmas.state_of_S
val state_of_S (s: machine_state) : GTot vale_state
val state_of_S (s: machine_state) : GTot vale_state
let state_of_S (s:machine_state) : GTot vale_state = let open Ms in { vs_ok = s.ms_ok; vs_regs = Regs.of_fun s.ms_regs; vs_flags = Flags.of_fun s.ms_flags; vs_heap = coerce s.ms_heap; vs_stack = VSS.stack_from_s s.ms_stack; vs_stackTaint = s.ms_stackTaint; }
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 63, "start_col": 0, "start_line": 54 }
module Vale.X64.StateLemmas open Vale.X64.Machine_s open Vale.Arch.Heap open Vale.X64.State open FStar.FunctionalExtensionality module Ms = Vale.X64.Machine_Semantics_s //open Vale.X64.Machine_Semantics_s //module ME = Vale.X64.Memory open Vale.X64.Memory open Vale.Arch.MachineHeap_s //module MS = Vale.X64.Memory_Sems module VSS = Vale.X64.Stack_Sems module F = FStar.FunctionalExtensionality open Vale.Def.Prop_s open FStar.Mul unfold let machine_state = Ms.machine_state unfold let code = Ms.code unfold let machine_eval_code = Ms.machine_eval_code val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x let machine_state_eq (s1 s2:machine_state) = s1 == s2 let machine_state_equal (s1 s2:machine_state) = let open Vale.X64.Machine_Semantics_s in s1.ms_ok == s2.ms_ok /\ F.feq s1.ms_regs s2.ms_regs /\ F.feq s1.ms_flags s2.ms_flags /\ s1.ms_heap == s2.ms_heap /\ s1.ms_stack == s2.ms_stack /\ s1.ms_stackTaint == s2.ms_stackTaint /\ s1.ms_trace == s2.ms_trace /\ True val use_machine_state_equal (_:unit) : Lemma (requires True) (ensures forall (s1 s2:machine_state).{:pattern machine_state_eq s1 s2} machine_state_equal s1 s2 ==> machine_state_eq s1 s2) let state_to_S (s:vale_state) : GTot machine_state = let open Ms in { ms_ok = s.vs_ok; ms_regs = Regs.to_fun s.vs_regs; ms_flags = Flags.to_fun s.vs_flags; ms_heap = coerce s.vs_heap; ms_stack = VSS.stack_to_s s.vs_stack; ms_stackTaint = s.vs_stackTaint; ms_trace = []; }
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Regs.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.StateLemmas.fsti" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.X64.Stack_i", "short_module": "VST" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.X64.Memory_Sems", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "Ms" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
s: Vale.X64.StateLemmas.machine_state -> Prims.GTot Vale.X64.State.vale_state
Prims.GTot
[ "sometrivial" ]
[]
[ "Vale.X64.StateLemmas.machine_state", "Vale.X64.State.Mkvale_state", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok", "Vale.X64.Regs.of_fun", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Flags.of_fun", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags", "Vale.X64.StateLemmas.coerce", "Vale.X64.Memory.vale_full_heap", "Vale.Arch.Heap.heap_impl", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Stack_Sems.stack_from_s", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Vale.X64.State.vale_state" ]
[]
false
false
false
false
false
let state_of_S (s: machine_state) : GTot vale_state =
let open Ms in { vs_ok = s.ms_ok; vs_regs = Regs.of_fun s.ms_regs; vs_flags = Flags.of_fun s.ms_flags; vs_heap = coerce s.ms_heap; vs_stack = VSS.stack_from_s s.ms_stack; vs_stackTaint = s.ms_stackTaint }
false
CDDL.Pulse.fst
CDDL.Pulse.cbor_read_deterministically_encoded_with_typ_post
val cbor_read_deterministically_encoded_with_typ_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop
val cbor_read_deterministically_encoded_with_typ_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop
let cbor_read_deterministically_encoded_with_typ_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop = if res.cbor_read_is_success then cbor_read_deterministically_encoded_with_typ_success_post t a p va res else cbor_read_deterministically_encoded_with_typ_error_post t a p va
{ "file_name": "share/steel/examples/pulse/dice/cbor/CDDL.Pulse.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 71, "end_line": 563, "start_col": 0, "start_line": 554 }
(* 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 CDDL.Pulse open Pulse.Lib.Pervasives open Pulse.Lib.Stick open CBOR.Spec open CBOR.Pulse open CDDL.Spec module R = Pulse.Lib.Reference inline_for_extraction noextract [@@noextract_to "krml"] let impl_typ (#b: option raw_data_item) (t: bounded_typ_gen b) = (c: cbor) -> (#p: perm) -> (#v: Ghost.erased raw_data_item) -> stt bool (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b )) (fun res -> raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) b /\ res == t v )) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_coerce_to_bounded_typ (b: Ghost.erased (option raw_data_item)) (#t: typ) (f: impl_typ t) : impl_typ #b (coerce_to_bounded_typ b t) // FIXME: WHY WHY WHY do I need to provide the implicit argument = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { f c; } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_choice (#b: Ghost.erased (option raw_data_item)) (#t1 #t2: bounded_typ_gen b) (f1: impl_typ t1) (f2: impl_typ t2) : impl_typ #b (t_choice t1 t2) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let test = f1 c; if (test) { true } else { f2 c } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_t_choice_none // FIXME: WHY WHY WHY can F* not automatically infer t1 and t2 by reducing (reveal (hide None)) to None? (#t1 #t2: bounded_typ_gen None) (f1: impl_typ t1) (f2: impl_typ t2) : Tot (impl_typ (t_choice t1 t2)) = impl_t_choice #None #t1 #t2 f1 f2 inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_any (_: unit) : impl_typ #None any = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { true } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint (_: unit) : impl_typ #None uint = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_uint64) } ``` module U64 = FStar.UInt64 (* FIXME: WHY WHY WHY does this one not work? inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal (n: U64.t) : impl_typ #None (t_uint_literal n) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; if (mt = major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` *) inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_uint_literal' (n: U64.t) (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) requires (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) )) returns res: bool ensures (raw_data_item_match p c v ** pure ( opt_precedes (Ghost.reveal v) (None #raw_data_item) /\ res == t_uint_literal n v )) { let mt = cbor_get_major_type c; if (mt = cbor_major_type_uint64) { let i = cbor_destr_int64 c; (i.cbor_int_value = n) } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_uint_literal (n: U64.t) : impl_typ (t_uint_literal n) = impl_uint_literal' n inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_bytes (_: unit) : impl_typ #None bytes = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let mt = cbor_get_major_type c; (mt = cbor_major_type_byte_string) } ``` inline_for_extraction noextract [@@noextract_to "krml"] let impl_array_group3 (#b: Ghost.erased (option raw_data_item)) (g: array_group3 b) = (pi: R.ref cbor_array_iterator_t) -> (#p: perm) -> (#i: Ghost.erased cbor_array_iterator_t) -> (#l: Ghost.erased (list raw_data_item)) -> stt bool (R.pts_to pi i ** cbor_array_iterator_match p i l ** pure (opt_precedes (Ghost.reveal l) b) ) (fun res -> exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ```pulse ghost fn intro_impl_array_group3_post (#b: option raw_data_item) (g: array_group3 b) (pi: R.ref cbor_array_iterator_t) (p: perm) (i: cbor_array_iterator_t) (l: list raw_data_item) (res: bool) (i': cbor_array_iterator_t) (l': list raw_data_item) requires ( R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) ensures (exists* i' l'. R.pts_to pi i' ** cbor_array_iterator_match p i' l' ** (cbor_array_iterator_match p i' l' @==> cbor_array_iterator_match p i l) ** pure ( opt_precedes (Ghost.reveal l) b /\ res == Some? (g l) /\ (res == true ==> Some?.v (g l) == l') ) ) { () } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_concat (#b: Ghost.erased (option raw_data_item)) (#g1: array_group3 b) (f1: impl_array_group3 g1) (#g2: array_group3 b) (f2: impl_array_group3 g2) : impl_array_group3 #b (array_group3_concat g1 g2) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let test1 = f1 pi; if (test1) { let test2 = f2 pi; stick_trans (); test2 } else { false } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_array_group3_item (#b: Ghost.erased (option raw_data_item)) (#ty: bounded_typ_gen b) (fty: impl_typ ty) : impl_array_group3 #b (array_group3_item ty) = (pi: R.ref cbor_array_iterator_t) (#p: perm) (#gi: Ghost.erased cbor_array_iterator_t) (#l: Ghost.erased (list raw_data_item)) { let i = !pi; rewrite (cbor_array_iterator_match p gi l) as (cbor_array_iterator_match p i l); let is_done = cbor_array_iterator_is_done i; rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p gi l); if (is_done) { stick_refl0 (cbor_array_iterator_match p gi l); intro_impl_array_group3_post (array_group3_item ty) pi p gi l false gi l; // FIXME: WHY WHY WHY? and also WHY WHY WHY here and not in the other "false" case below? false } else { let c = cbor_array_iterator_next pi #p #l #gi; // FIXME: WHY WHY WHY those explicit arguments? with gc i' l' . assert ( raw_data_item_match p c gc ** cbor_array_iterator_match p i' l' ** ((raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') @==> cbor_array_iterator_match p gi l) ); // this is needed for the explicit arguments to split_consume_l below let test = fty c; if (test) { stick_consume_l () #(raw_data_item_match p c gc) #(cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l) // FIXME: WHY WHY WHY those explicit arguments? (for which the with above is needed) ; true } else { elim_stick0 () #(raw_data_item_match p c gc ** cbor_array_iterator_match p i' l') #(cbor_array_iterator_match p gi l); // FIXME: WHY WHY WHY those explicit arguments? pi := i; rewrite (R.pts_to pi i) as (R.pts_to pi gi); stick_refl0 (cbor_array_iterator_match p gi l); false } } } ``` inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn impl_t_array (#b: Ghost.erased (option raw_data_item)) (#g: (array_group3 b)) (ig: (impl_array_group3 (g))) : impl_typ #b (t_array3 g) = (c: cbor) (#p: perm) (#v: Ghost.erased raw_data_item) { let ty = cbor_get_major_type c; if (ty = cbor_major_type_array) { let i = cbor_array_iterator_init c; with l . assert (cbor_array_iterator_match p i l); rewrite (cbor_array_iterator_match p i l) as (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l); let mut pi = i; let b_success = ig pi; with gi' l' . assert (cbor_array_iterator_match p gi' l'); let i' = ! pi; rewrite (cbor_array_iterator_match p gi' l') as (cbor_array_iterator_match p i' l'); let b_end = cbor_array_iterator_is_done i'; rewrite (cbor_array_iterator_match p i' l') as (cbor_array_iterator_match p gi' l'); elim_stick0 (); rewrite (cbor_array_iterator_match p (Ghost.reveal (Ghost.hide i)) l) as (cbor_array_iterator_match p i l); elim_stick0 (); (b_success && b_end) } else { false } } ``` module U8 = FStar.UInt8 noextract [@@noextract_to "krml"] let cbor_read_with_typ_success_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Tot prop = cbor_read_success_postcond va c v rem /\ t v == true module A = Pulse.Lib.Array let cbor_read_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) : Tot vprop = exists* v rem. raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem ** ((raw_data_item_match full_perm c.cbor_read_payload v ** A.pts_to c.cbor_read_remainder #p rem) @==> A.pts_to a #p va) ** pure (cbor_read_with_typ_success_postcond t va c v rem) noextract [@@noextract_to "krml"] let cbor_read_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop = forall v suff . Ghost.reveal va == serialize_cbor v `Seq.append` suff ==> t v == false let cbor_read_with_typ_error_postcond_intro_typ_fail (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Lemma (requires ( cbor_read_success_postcond va c v rem /\ t v == false )) (ensures ( cbor_read_with_typ_error_postcond t va )) = serialize_cbor_with_test_correct v rem (fun v' rem' -> t v' == true) let cbor_read_with_typ_error_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) : Tot vprop = A.pts_to a #p va ** pure (cbor_read_with_typ_error_postcond t va) let cbor_read_with_typ_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop = if res.cbor_read_is_success then cbor_read_with_typ_success_post t a p va res else cbor_read_with_typ_error_post t a p va module SZ = FStar.SizeT inline_for_extraction noextract let mk_cbor_read_error (res: cbor_read_t) : Tot cbor_read_t = {res with cbor_read_is_success = false} inline_for_extraction noextract [@@noextract_to "krml"] ```pulse fn cbor_read_with_typ (#t: typ) (ft: impl_typ t) (a: A.array U8.t) (sz: SZ.t) (#va: Ghost.erased (Seq.seq U8.t)) (#p: perm) requires (A.pts_to a #p va ** pure ( (SZ.v sz == Seq.length va \/ SZ.v sz == A.length a) )) returns res: cbor_read_t ensures cbor_read_with_typ_post t a p va res { let res = cbor_read a sz; if (res.cbor_read_is_success) { rewrite (cbor_read_post a p va res) as (cbor_read_success_post a p va res); unfold (cbor_read_success_post a p va res); let test = ft res.cbor_read_payload; if (test) { fold (cbor_read_with_typ_success_post t a p va res); rewrite (cbor_read_with_typ_success_post t a p va res) as (cbor_read_with_typ_post t a p va res); res } else { with v . assert (raw_data_item_match full_perm res.cbor_read_payload v); with vrem . assert (A.pts_to res.cbor_read_remainder #p vrem); cbor_read_with_typ_error_postcond_intro_typ_fail t va res v vrem; elim_stick0 () #(raw_data_item_match full_perm res.cbor_read_payload v ** A.pts_to res.cbor_read_remainder #p vrem); fold (cbor_read_with_typ_error_post t a p va); let res = mk_cbor_read_error res; rewrite (cbor_read_with_typ_error_post t a p va) as (cbor_read_with_typ_post t a p va res); res } } else { rewrite (cbor_read_post a p va res) as (cbor_read_error_post a p va); unfold (cbor_read_error_post a p va); fold (cbor_read_with_typ_error_post t a p va); rewrite (cbor_read_with_typ_error_post t a p va) as (cbor_read_with_typ_post t a p va res); res } } ``` noextract [@@noextract_to "krml"] let cbor_read_deterministically_encoded_with_typ_success_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Tot prop = cbor_read_deterministically_encoded_success_postcond va c v rem /\ t v == true noextract [@@noextract_to "krml"] let cbor_read_deterministically_encoded_with_typ_error_postcond (t: typ) (va: Ghost.erased (Seq.seq U8.t)) : Tot prop = forall v suff . (Ghost.reveal va == serialize_cbor v `Seq.append` suff /\ data_item_wf deterministically_encoded_cbor_map_key_order v == true ) ==> t v == false let cbor_read_deterministically_encoded_with_typ_error_postcond_intro_typ_fail (t: typ) (va: Ghost.erased (Seq.seq U8.t)) (c: cbor_read_t) (v: raw_data_item) (rem: Seq.seq U8.t) : Lemma (requires ( cbor_read_deterministically_encoded_success_postcond va c v rem /\ t v == false )) (ensures ( cbor_read_deterministically_encoded_with_typ_error_postcond t va )) = serialize_cbor_with_test_correct v rem (fun v' rem' -> data_item_wf deterministically_encoded_cbor_map_key_order v' == true /\ t v' == true) let cbor_read_deterministically_encoded_with_typ_success_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop = exists* v rem. raw_data_item_match full_perm res.cbor_read_payload v ** A.pts_to res.cbor_read_remainder #p rem ** ((raw_data_item_match full_perm res.cbor_read_payload v ** A.pts_to res.cbor_read_remainder #p rem) @==> A.pts_to a #p va) ** pure (cbor_read_deterministically_encoded_with_typ_success_postcond t va res v rem) let cbor_read_deterministically_encoded_with_typ_error_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) : Tot vprop = A.pts_to a #p va ** pure (cbor_read_deterministically_encoded_with_typ_error_postcond t va)
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Stick.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CDDL.Spec.fsti.checked", "CBOR.Spec.fsti.checked", "CBOR.Pulse.fst.checked" ], "interface_file": false, "source_file": "CDDL.Pulse.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "CDDL.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Pulse", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Stick", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "CDDL", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: CDDL.Spec.typ -> a: Pulse.Lib.Array.Core.array FStar.UInt8.t -> p: PulseCore.FractionalPermission.perm -> va: FStar.Ghost.erased (FStar.Seq.Base.seq FStar.UInt8.t) -> res: CBOR.Pulse.Extern.cbor_read_t -> Pulse.Lib.Core.vprop
Prims.Tot
[ "total" ]
[]
[ "CDDL.Spec.typ", "Pulse.Lib.Array.Core.array", "FStar.UInt8.t", "PulseCore.FractionalPermission.perm", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "CBOR.Pulse.Extern.cbor_read_t", "CBOR.Pulse.Extern.__proj__Mkcbor_read_t__item__cbor_read_is_success", "CDDL.Pulse.cbor_read_deterministically_encoded_with_typ_success_post", "Prims.bool", "CDDL.Pulse.cbor_read_deterministically_encoded_with_typ_error_post", "Pulse.Lib.Core.vprop" ]
[]
false
false
false
true
false
let cbor_read_deterministically_encoded_with_typ_post (t: typ) (a: A.array U8.t) (p: perm) (va: Ghost.erased (Seq.seq U8.t)) (res: cbor_read_t) : Tot vprop =
if res.cbor_read_is_success then cbor_read_deterministically_encoded_with_typ_success_post t a p va res else cbor_read_deterministically_encoded_with_typ_error_post t a p va
false
MSort.SeqLemmas.fst
MSort.SeqLemmas.nil_app_l
val nil_app_l (#a: _) (s: S.seq a) : Lemma (S.append S.empty s == s) [SMTPat (S.append S.empty s)]
val nil_app_l (#a: _) (s: S.seq a) : Lemma (S.append S.empty s == s) [SMTPat (S.append S.empty s)]
let nil_app_l #a (s : S.seq a) : Lemma (S.append S.empty s == s) [SMTPat (S.append S.empty s)] = S.append_empty_l s
{ "file_name": "share/steel/examples/pulse/MSort.SeqLemmas.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 22, "end_line": 92, "start_col": 0, "start_line": 89 }
module MSort.SeqLemmas open FStar.Ghost module S = FStar.Seq assume val sort : Seq.seq int -> Seq.seq int assume val sorted : Seq.seq int -> bool assume val sort_is_sorted (s:Seq.seq int) : Lemma (sorted (sort s)) assume val sort_len (s:Seq.seq int) : Lemma (S.length (sort s) == S.length s) [SMTPat (S.length (sort s))] assume val singl_is_sorted (s : S.seq int) : Lemma (requires S.length s < 2) (ensures s == sort s) type seq_view a = | Nil | Cons : a -> S.seq a -> seq_view a let view #a (s : S.seq a) : seq_view a = if S.length s = 0 then Nil else Cons (S.head s) (S.tail s) val merge : Seq.seq int -> Seq.seq int -> Seq.seq int let rec merge s1 s2 : Tot (S.seq int) (decreases S.length s1 + S.length s2) = match view s1, view s2 with | Nil, Nil -> S.empty | Nil, Cons h t -> S.cons h t | Cons h t, Nil -> S.cons h t | Cons h1 t1, Cons h2 t2 -> if h1 <= h2 then S.cons h1 (merge t1 s2) else S.cons h2 (merge s1 t2) assume val merge_len (s1 s2 : S.seq int) : Lemma (ensures S.length (merge s1 s2) == S.length s1 + S.length s2) [SMTPat (merge s1 s2)] assume val merge_sorted' (s1 s2 : S.seq int) : Lemma (ensures merge (sort s1) (sort s2) == sort (s1 `S.append` s2)) [SMTPat (merge (sort s1) (sort s2))] assume val merge_sorted (s1 s2 : S.seq int) : Lemma (requires sorted s1 /\ sorted s2) (ensures sorted (merge s1 s2)) [SMTPat (sorted (merge s1 s2))] val append_slice #a (s : S.seq a) (l1:nat) (l2 : nat{S.length s == l2 /\ l1 <= l2}) : Lemma (S.append (S.slice s 0 l1) (S.slice s l1 l2) == s) [SMTPat (S.append (S.slice s 0 l1) (S.slice s l1 l2))] let append_slice s l1 l2 = assert (S.equal (S.append (S.slice s 0 l1) (S.slice s l1 l2)) s); () (* These two must be total or the invariant of the loop fails to typecheck. I think the problem is that the pure assertions within the invariant are not used to typecheck the other components of the invariant. *) let stake #a (i:nat) (s : S.seq a) : Tot (S.seq a) = if i <= S.length s then S.slice s 0 i else s let sdrop #a (i:nat) (s : S.seq a) : Tot (S.seq a) = if i <= S.length s then S.slice s i (S.length s) else S.empty let take_0_lem #a (s : S.seq a) : Lemma (stake 0 s == S.empty) [SMTPat (stake 0 s)] = () let drop_0_lem #a (s : S.seq a) : Lemma (sdrop 0 s == s) [SMTPat (sdrop 0 s)] = () let take_len_lem #a (s : S.seq a) : Lemma (stake (S.length s) s == s) [SMTPat (stake (S.length s) s)] = () let drop_len_lem #a (s : S.seq a) : Lemma (sdrop (S.length s) s == S.empty) [SMTPat (sdrop (S.length s) s)] = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "MSort.SeqLemmas.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "MSort", "short_module": null }, { "abbrev": false, "full_module": "MSort", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.append FStar.Seq.Base.empty s == s) [SMTPat (FStar.Seq.Base.append FStar.Seq.Base.empty s)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "FStar.Seq.Base.append_empty_l", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Seq.Base.append", "FStar.Seq.Base.empty", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
true
false
true
false
false
let nil_app_l #a (s: S.seq a) : Lemma (S.append S.empty s == s) [SMTPat (S.append S.empty s)] =
S.append_empty_l s
false
MSort.SeqLemmas.fst
MSort.SeqLemmas.nil_app_r
val nil_app_r (#a: _) (s: S.seq a) : Lemma (S.append s S.empty == s) [SMTPat (S.append s S.empty)]
val nil_app_r (#a: _) (s: S.seq a) : Lemma (S.append s S.empty == s) [SMTPat (S.append s S.empty)]
let nil_app_r #a (s : S.seq a) : Lemma (S.append s S.empty == s) [SMTPat (S.append s S.empty)] = S.append_empty_r s
{ "file_name": "share/steel/examples/pulse/MSort.SeqLemmas.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 22, "end_line": 96, "start_col": 0, "start_line": 93 }
module MSort.SeqLemmas open FStar.Ghost module S = FStar.Seq assume val sort : Seq.seq int -> Seq.seq int assume val sorted : Seq.seq int -> bool assume val sort_is_sorted (s:Seq.seq int) : Lemma (sorted (sort s)) assume val sort_len (s:Seq.seq int) : Lemma (S.length (sort s) == S.length s) [SMTPat (S.length (sort s))] assume val singl_is_sorted (s : S.seq int) : Lemma (requires S.length s < 2) (ensures s == sort s) type seq_view a = | Nil | Cons : a -> S.seq a -> seq_view a let view #a (s : S.seq a) : seq_view a = if S.length s = 0 then Nil else Cons (S.head s) (S.tail s) val merge : Seq.seq int -> Seq.seq int -> Seq.seq int let rec merge s1 s2 : Tot (S.seq int) (decreases S.length s1 + S.length s2) = match view s1, view s2 with | Nil, Nil -> S.empty | Nil, Cons h t -> S.cons h t | Cons h t, Nil -> S.cons h t | Cons h1 t1, Cons h2 t2 -> if h1 <= h2 then S.cons h1 (merge t1 s2) else S.cons h2 (merge s1 t2) assume val merge_len (s1 s2 : S.seq int) : Lemma (ensures S.length (merge s1 s2) == S.length s1 + S.length s2) [SMTPat (merge s1 s2)] assume val merge_sorted' (s1 s2 : S.seq int) : Lemma (ensures merge (sort s1) (sort s2) == sort (s1 `S.append` s2)) [SMTPat (merge (sort s1) (sort s2))] assume val merge_sorted (s1 s2 : S.seq int) : Lemma (requires sorted s1 /\ sorted s2) (ensures sorted (merge s1 s2)) [SMTPat (sorted (merge s1 s2))] val append_slice #a (s : S.seq a) (l1:nat) (l2 : nat{S.length s == l2 /\ l1 <= l2}) : Lemma (S.append (S.slice s 0 l1) (S.slice s l1 l2) == s) [SMTPat (S.append (S.slice s 0 l1) (S.slice s l1 l2))] let append_slice s l1 l2 = assert (S.equal (S.append (S.slice s 0 l1) (S.slice s l1 l2)) s); () (* These two must be total or the invariant of the loop fails to typecheck. I think the problem is that the pure assertions within the invariant are not used to typecheck the other components of the invariant. *) let stake #a (i:nat) (s : S.seq a) : Tot (S.seq a) = if i <= S.length s then S.slice s 0 i else s let sdrop #a (i:nat) (s : S.seq a) : Tot (S.seq a) = if i <= S.length s then S.slice s i (S.length s) else S.empty let take_0_lem #a (s : S.seq a) : Lemma (stake 0 s == S.empty) [SMTPat (stake 0 s)] = () let drop_0_lem #a (s : S.seq a) : Lemma (sdrop 0 s == s) [SMTPat (sdrop 0 s)] = () let take_len_lem #a (s : S.seq a) : Lemma (stake (S.length s) s == s) [SMTPat (stake (S.length s) s)] = () let drop_len_lem #a (s : S.seq a) : Lemma (sdrop (S.length s) s == S.empty) [SMTPat (sdrop (S.length s) s)] = () // let nil_app_l #a (s : S.seq a) : Lemma (S.append S.empty s == s) [SMTPat (S.append S.empty s)]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "MSort.SeqLemmas.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "MSort", "short_module": null }, { "abbrev": false, "full_module": "MSort", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.append s FStar.Seq.Base.empty == s) [SMTPat (FStar.Seq.Base.append s FStar.Seq.Base.empty)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "FStar.Seq.Base.append_empty_r", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Seq.Base.append", "FStar.Seq.Base.empty", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
true
false
true
false
false
let nil_app_r #a (s: S.seq a) : Lemma (S.append s S.empty == s) [SMTPat (S.append s S.empty)] =
S.append_empty_r s
false
MSort.SeqLemmas.fst
MSort.SeqLemmas.merge
val merge : Seq.seq int -> Seq.seq int -> Seq.seq int
val merge : Seq.seq int -> Seq.seq int -> Seq.seq int
let rec merge s1 s2 : Tot (S.seq int) (decreases S.length s1 + S.length s2) = match view s1, view s2 with | Nil, Nil -> S.empty | Nil, Cons h t -> S.cons h t | Cons h t, Nil -> S.cons h t | Cons h1 t1, Cons h2 t2 -> if h1 <= h2 then S.cons h1 (merge t1 s2) else S.cons h2 (merge s1 t2)
{ "file_name": "share/steel/examples/pulse/MSort.SeqLemmas.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 73, "end_line": 31, "start_col": 0, "start_line": 25 }
module MSort.SeqLemmas open FStar.Ghost module S = FStar.Seq assume val sort : Seq.seq int -> Seq.seq int assume val sorted : Seq.seq int -> bool assume val sort_is_sorted (s:Seq.seq int) : Lemma (sorted (sort s)) assume val sort_len (s:Seq.seq int) : Lemma (S.length (sort s) == S.length s) [SMTPat (S.length (sort s))] assume val singl_is_sorted (s : S.seq int) : Lemma (requires S.length s < 2) (ensures s == sort s) type seq_view a = | Nil | Cons : a -> S.seq a -> seq_view a let view #a (s : S.seq a) : seq_view a = if S.length s = 0 then Nil else Cons (S.head s) (S.tail s)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "MSort.SeqLemmas.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "MSort", "short_module": null }, { "abbrev": false, "full_module": "MSort", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
s1: FStar.Seq.Base.seq Prims.int -> s2: FStar.Seq.Base.seq Prims.int -> Prims.Tot (FStar.Seq.Base.seq Prims.int)
Prims.Tot
[ "", "total" ]
[]
[ "FStar.Seq.Base.seq", "Prims.int", "FStar.Pervasives.Native.Mktuple2", "MSort.SeqLemmas.seq_view", "MSort.SeqLemmas.view", "FStar.Seq.Base.empty", "FStar.Seq.Base.cons", "Prims.op_LessThanOrEqual", "MSort.SeqLemmas.merge", "Prims.bool" ]
[ "recursion" ]
false
false
false
true
false
let rec merge s1 s2 : Tot (S.seq int) (decreases S.length s1 + S.length s2) =
match view s1, view s2 with | Nil, Nil -> S.empty | Nil, Cons h t -> S.cons h t | Cons h t, Nil -> S.cons h t | Cons h1 t1, Cons h2 t2 -> if h1 <= h2 then S.cons h1 (merge t1 s2) else S.cons h2 (merge s1 t2)
false
MSort.SeqLemmas.fst
MSort.SeqLemmas.sdrop
val sdrop (#a: _) (i: nat) (s: S.seq a) : Tot (S.seq a)
val sdrop (#a: _) (i: nat) (s: S.seq a) : Tot (S.seq a)
let sdrop #a (i:nat) (s : S.seq a) : Tot (S.seq a) = if i <= S.length s then S.slice s i (S.length s) else S.empty
{ "file_name": "share/steel/examples/pulse/MSort.SeqLemmas.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 14, "end_line": 67, "start_col": 0, "start_line": 63 }
module MSort.SeqLemmas open FStar.Ghost module S = FStar.Seq assume val sort : Seq.seq int -> Seq.seq int assume val sorted : Seq.seq int -> bool assume val sort_is_sorted (s:Seq.seq int) : Lemma (sorted (sort s)) assume val sort_len (s:Seq.seq int) : Lemma (S.length (sort s) == S.length s) [SMTPat (S.length (sort s))] assume val singl_is_sorted (s : S.seq int) : Lemma (requires S.length s < 2) (ensures s == sort s) type seq_view a = | Nil | Cons : a -> S.seq a -> seq_view a let view #a (s : S.seq a) : seq_view a = if S.length s = 0 then Nil else Cons (S.head s) (S.tail s) val merge : Seq.seq int -> Seq.seq int -> Seq.seq int let rec merge s1 s2 : Tot (S.seq int) (decreases S.length s1 + S.length s2) = match view s1, view s2 with | Nil, Nil -> S.empty | Nil, Cons h t -> S.cons h t | Cons h t, Nil -> S.cons h t | Cons h1 t1, Cons h2 t2 -> if h1 <= h2 then S.cons h1 (merge t1 s2) else S.cons h2 (merge s1 t2) assume val merge_len (s1 s2 : S.seq int) : Lemma (ensures S.length (merge s1 s2) == S.length s1 + S.length s2) [SMTPat (merge s1 s2)] assume val merge_sorted' (s1 s2 : S.seq int) : Lemma (ensures merge (sort s1) (sort s2) == sort (s1 `S.append` s2)) [SMTPat (merge (sort s1) (sort s2))] assume val merge_sorted (s1 s2 : S.seq int) : Lemma (requires sorted s1 /\ sorted s2) (ensures sorted (merge s1 s2)) [SMTPat (sorted (merge s1 s2))] val append_slice #a (s : S.seq a) (l1:nat) (l2 : nat{S.length s == l2 /\ l1 <= l2}) : Lemma (S.append (S.slice s 0 l1) (S.slice s l1 l2) == s) [SMTPat (S.append (S.slice s 0 l1) (S.slice s l1 l2))] let append_slice s l1 l2 = assert (S.equal (S.append (S.slice s 0 l1) (S.slice s l1 l2)) s); () (* These two must be total or the invariant of the loop fails to typecheck. I think the problem is that the pure assertions within the invariant are not used to typecheck the other components of the invariant. *) let stake #a (i:nat) (s : S.seq a) : Tot (S.seq a) = if i <= S.length s then S.slice s 0 i else s
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "MSort.SeqLemmas.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "MSort", "short_module": null }, { "abbrev": false, "full_module": "MSort", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
i: Prims.nat -> s: FStar.Seq.Base.seq a -> FStar.Seq.Base.seq a
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.Seq.Base.seq", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "FStar.Seq.Base.slice", "Prims.bool", "FStar.Seq.Base.empty" ]
[]
false
false
false
true
false
let sdrop #a (i: nat) (s: S.seq a) : Tot (S.seq a) =
if i <= S.length s then S.slice s i (S.length s) else S.empty
false
MSort.SeqLemmas.fst
MSort.SeqLemmas.stake
val stake (#a: _) (i: nat) (s: S.seq a) : Tot (S.seq a)
val stake (#a: _) (i: nat) (s: S.seq a) : Tot (S.seq a)
let stake #a (i:nat) (s : S.seq a) : Tot (S.seq a) = if i <= S.length s then S.slice s 0 i else s
{ "file_name": "share/steel/examples/pulse/MSort.SeqLemmas.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 8, "end_line": 61, "start_col": 0, "start_line": 57 }
module MSort.SeqLemmas open FStar.Ghost module S = FStar.Seq assume val sort : Seq.seq int -> Seq.seq int assume val sorted : Seq.seq int -> bool assume val sort_is_sorted (s:Seq.seq int) : Lemma (sorted (sort s)) assume val sort_len (s:Seq.seq int) : Lemma (S.length (sort s) == S.length s) [SMTPat (S.length (sort s))] assume val singl_is_sorted (s : S.seq int) : Lemma (requires S.length s < 2) (ensures s == sort s) type seq_view a = | Nil | Cons : a -> S.seq a -> seq_view a let view #a (s : S.seq a) : seq_view a = if S.length s = 0 then Nil else Cons (S.head s) (S.tail s) val merge : Seq.seq int -> Seq.seq int -> Seq.seq int let rec merge s1 s2 : Tot (S.seq int) (decreases S.length s1 + S.length s2) = match view s1, view s2 with | Nil, Nil -> S.empty | Nil, Cons h t -> S.cons h t | Cons h t, Nil -> S.cons h t | Cons h1 t1, Cons h2 t2 -> if h1 <= h2 then S.cons h1 (merge t1 s2) else S.cons h2 (merge s1 t2) assume val merge_len (s1 s2 : S.seq int) : Lemma (ensures S.length (merge s1 s2) == S.length s1 + S.length s2) [SMTPat (merge s1 s2)] assume val merge_sorted' (s1 s2 : S.seq int) : Lemma (ensures merge (sort s1) (sort s2) == sort (s1 `S.append` s2)) [SMTPat (merge (sort s1) (sort s2))] assume val merge_sorted (s1 s2 : S.seq int) : Lemma (requires sorted s1 /\ sorted s2) (ensures sorted (merge s1 s2)) [SMTPat (sorted (merge s1 s2))] val append_slice #a (s : S.seq a) (l1:nat) (l2 : nat{S.length s == l2 /\ l1 <= l2}) : Lemma (S.append (S.slice s 0 l1) (S.slice s l1 l2) == s) [SMTPat (S.append (S.slice s 0 l1) (S.slice s l1 l2))] let append_slice s l1 l2 = assert (S.equal (S.append (S.slice s 0 l1) (S.slice s l1 l2)) s); () (* These two must be total or the invariant of the loop fails to typecheck. I think the problem is that the pure assertions within the invariant are not
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "MSort.SeqLemmas.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "MSort", "short_module": null }, { "abbrev": false, "full_module": "MSort", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
i: Prims.nat -> s: FStar.Seq.Base.seq a -> FStar.Seq.Base.seq a
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.Seq.Base.seq", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "FStar.Seq.Base.slice", "Prims.bool" ]
[]
false
false
false
true
false
let stake #a (i: nat) (s: S.seq a) : Tot (S.seq a) =
if i <= S.length s then S.slice s 0 i else s
false
MSort.SeqLemmas.fst
MSort.SeqLemmas.view
val view (#a: _) (s: S.seq a) : seq_view a
val view (#a: _) (s: S.seq a) : seq_view a
let view #a (s : S.seq a) : seq_view a = if S.length s = 0 then Nil else Cons (S.head s) (S.tail s)
{ "file_name": "share/steel/examples/pulse/MSort.SeqLemmas.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 60, "end_line": 22, "start_col": 0, "start_line": 21 }
module MSort.SeqLemmas open FStar.Ghost module S = FStar.Seq assume val sort : Seq.seq int -> Seq.seq int assume val sorted : Seq.seq int -> bool assume val sort_is_sorted (s:Seq.seq int) : Lemma (sorted (sort s)) assume val sort_len (s:Seq.seq int) : Lemma (S.length (sort s) == S.length s) [SMTPat (S.length (sort s))] assume val singl_is_sorted (s : S.seq int) : Lemma (requires S.length s < 2) (ensures s == sort s) type seq_view a = | Nil | Cons : a -> S.seq a -> seq_view a
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "MSort.SeqLemmas.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "MSort", "short_module": null }, { "abbrev": false, "full_module": "MSort", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq a -> MSort.SeqLemmas.seq_view a
Prims.Tot
[ "total" ]
[]
[ "FStar.Seq.Base.seq", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length", "MSort.SeqLemmas.Nil", "Prims.bool", "MSort.SeqLemmas.Cons", "FStar.Seq.Properties.head", "FStar.Seq.Properties.tail", "MSort.SeqLemmas.seq_view" ]
[]
false
false
false
true
false
let view #a (s: S.seq a) : seq_view a =
if S.length s = 0 then Nil else Cons (S.head s) (S.tail s)
false