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
LList2.fst
LList2.intro_llist_cons
val intro_llist_cons (#opened: _) (p1: ref cell) (#v1: Ghost.erased (typeof cell)) (p2: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) : STGhost unit opened (((pts_to p1 v1) `star` (llist p2 q)) `star` (freeable p1)) (fun _ -> llist p1 (a :: q)) (Ghost.reveal v1 == ({ hd = mk_scalar a; tl = mk_scalar p2 })) (fun _ -> True)
val intro_llist_cons (#opened: _) (p1: ref cell) (#v1: Ghost.erased (typeof cell)) (p2: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) : STGhost unit opened (((pts_to p1 v1) `star` (llist p2 q)) `star` (freeable p1)) (fun _ -> llist p1 (a :: q)) (Ghost.reveal v1 == ({ hd = mk_scalar a; tl = mk_scalar p2 })) (fun _ -> True)
let intro_llist_cons (#opened: _) (p1: ref cell) (#v1: Ghost.erased (typeof cell)) (p2: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) : STGhost unit opened (pts_to p1 v1 `star` llist p2 q `star` freeable p1 ) (fun _ -> llist p1 (a :: q)) (Ghost.reveal v1 == ({ hd = mk_scalar a; tl = mk_scalar p2 })) (fun _ -> True) = noop (); rewrite_with_tactic (llist_cons p1 a q llist) (llist p1 (a :: q))
{ "file_name": "share/steel/examples/steelc/LList2.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 67, "end_line": 69, "start_col": 0, "start_line": 57 }
module LList2 open Steel.ST.GenElim open Steel.ST.C.Types open Steel.ST.C.Types.Struct.Aux open Steel.ST.C.Types.UserStruct // hides Struct module U32 = FStar.UInt32 noeq type cell_t = { hd: scalar_t U32.t; tl: scalar_t (ptr_gen cell_t); } noextract inline_for_extraction [@@ norm_field_attr] let cell_struct_def : struct_def cell_t = let fields = FStar.Set.add "hd" (FStar.Set.singleton "tl") in let field_desc : field_description_gen_t (field_t fields) = { fd_nonempty = nonempty_set_nonempty_type "hd" fields; fd_type = (fun (n: field_t fields) -> match n with "hd" -> scalar_t U32.t | "tl" -> scalar_t (ptr_gen cell_t)); fd_typedef = (fun (n: field_t fields) -> match n with "hd" -> scalar U32.t | "tl" -> scalar (ptr_gen cell_t)); } in { fields = fields; field_desc = field_desc; mk = (fun f -> Mkcell_t (f "hd") (f "tl")); get = (fun x (f: field_t fields) -> match f with "hd" -> x.hd | "tl" -> x.tl); get_mk = (fun _ _ -> ()); extensionality = (fun s1 s2 phi -> phi "hd"; phi "tl"); } noextract inline_for_extraction [@@ norm_field_attr] let cell = struct_typedef cell_struct_def [@@__reduce__] let llist_nil (p: ptr cell) : Tot vprop = pure (p == null _) [@@__reduce__] let llist_cons (p: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) (llist: (ptr cell -> (l: Ghost.erased (list U32.t) { List.Tot.length l < List.Tot.length (a :: q) }) -> Tot vprop)) : Tot vprop = exists_ (fun (p1: ref cell) -> exists_ (fun (p2: ptr cell) -> pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar p2 }) `star` llist p2 q `star` freeable p1 `star` pure (p == p1) )) let rec llist (p: ptr cell) (l: Ghost.erased (list U32.t)) : Tot vprop (decreases (List.Tot.length l)) = match Ghost.reveal l with | [] -> llist_nil p | a :: q -> llist_cons p a q llist
{ "checked_file": "/", "dependencies": [ "Steel.ST.GenElim.fsti.checked", "Steel.ST.C.Types.UserStruct.fsti.checked", "Steel.ST.C.Types.Struct.Aux.fsti.checked", "Steel.ST.C.Types.fst.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LList2.fst" }
[ { "abbrev": false, "full_module": "Steel.ST.C.Types.UserStruct // hides Struct", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.ST.C.Types.UserStruct", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types.Struct.Aux", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p1: Steel.ST.C.Types.Base.ref LList2.cell -> p2: Steel.ST.C.Types.Base.ptr LList2.cell -> a: FStar.UInt32.t -> q: FStar.Ghost.erased (Prims.list FStar.UInt32.t) -> Steel.ST.Effect.Ghost.STGhost Prims.unit
Steel.ST.Effect.Ghost.STGhost
[]
[]
[ "Steel.Memory.inames", "Steel.ST.C.Types.Base.ref", "LList2.cell_t", "LList2.cell", "FStar.Ghost.erased", "Steel.ST.C.Types.Base.typeof", "Steel.ST.C.Types.Base.ptr", "FStar.UInt32.t", "Prims.list", "Steel.ST.Util.rewrite_with_tactic", "LList2.llist_cons", "LList2.llist", "FStar.Ghost.hide", "Prims.Cons", "FStar.Ghost.reveal", "Prims.unit", "Steel.ST.Util.noop", "Steel.Effect.Common.star", "Steel.ST.C.Types.Base.pts_to", "Steel.ST.C.Types.Base.freeable", "Steel.Effect.Common.vprop", "Prims.eq2", "LList2.Mkcell_t", "Steel.ST.C.Types.Scalar.mk_scalar", "Steel.ST.C.Types.Base.ptr_gen", "Prims.l_True" ]
[]
false
true
false
false
false
let intro_llist_cons (#opened: _) (p1: ref cell) (#v1: Ghost.erased (typeof cell)) (p2: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) : STGhost unit opened (((pts_to p1 v1) `star` (llist p2 q)) `star` (freeable p1)) (fun _ -> llist p1 (a :: q)) (Ghost.reveal v1 == ({ hd = mk_scalar a; tl = mk_scalar p2 })) (fun _ -> True) =
noop (); rewrite_with_tactic (llist_cons p1 a q llist) (llist p1 (a :: q))
false
FStar.Vector.Properties.fst
FStar.Vector.Properties.coerce
val coerce (#a: Type) (#l: len_t) (v: raw a l) (m: len_t{l == m}) : Tot (raw a m)
val coerce (#a: Type) (#l: len_t) (v: raw a l) (m: len_t{l == m}) : Tot (raw a m)
let coerce (#a:Type) (#l:len_t) (v:raw a l) (m:len_t{l == m}) : Tot (raw a m) = v
{ "file_name": "ulib/FStar.Vector.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 37, "start_col": 0, "start_line": 31 }
(* Copyright 2008-2017 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.Vector.Properties open FStar.Vector.Base module S = FStar.Seq module U32 = FStar.UInt32 /// This coercion seems to be necessary in some places /// /// For example, when trying to treat a `raw a (l1 +^ l2)` /// as a `raw a (m1 +^ m2)` /// F* type inference tries matches on the head symbol of the index /// and tries to prove `l1 = m1 /\ l2 = m2` /// which is often too strong. /// This coercion is a workaround for in such cases
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Vector.Base.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Vector.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Vector.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: FStar.Vector.Base.raw a l -> m: FStar.Vector.Base.len_t{l == m} -> FStar.Vector.Base.raw a m
Prims.Tot
[ "total" ]
[]
[ "FStar.Vector.Base.len_t", "FStar.Vector.Base.raw", "Prims.eq2" ]
[]
false
false
false
false
false
let coerce (#a: Type) (#l: len_t) (v: raw a l) (m: len_t{l == m}) : Tot (raw a m) =
v
false
FStar.Vector.Properties.fst
FStar.Vector.Properties.head
val head (#a: Type) (#l: len_t{l <> 0ul}) (v: raw a l) : Tot a
val head (#a: Type) (#l: len_t{l <> 0ul}) (v: raw a l) : Tot a
let head (#a:Type) (#l:len_t{l <> 0ul}) (v:raw a l) : Tot a = v.[0ul]
{ "file_name": "ulib/FStar.Vector.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 74, "start_col": 0, "start_line": 72 }
(* Copyright 2008-2017 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.Vector.Properties open FStar.Vector.Base module S = FStar.Seq module U32 = FStar.UInt32 /// This coercion seems to be necessary in some places /// /// For example, when trying to treat a `raw a (l1 +^ l2)` /// as a `raw a (m1 +^ m2)` /// F* type inference tries matches on the head symbol of the index /// and tries to prove `l1 = m1 /\ l2 = m2` /// which is often too strong. /// This coercion is a workaround for in such cases unfold let coerce (#a:Type) (#l:len_t) (v:raw a l) (m:len_t{l == m}) : Tot (raw a m) = v /// An abbreviation that states that some binary arithmetic /// operation on len_t's respects bouns unfold let ok (op:int -> int -> int) (l1:len_t) (l2:len_t) : Type = UInt.size U32.(op (v l1) (v l2)) U32.n /// Most lemmas from FStar.Seq.Properties can just be lifted /// to vectors, although the lengths have to be bounds checked let append_inj (#a:Type) (#l1:len_t) (#l2:len_t) (#m1:len_t) (#m2:len_t) (u1:raw a l1) (u2:raw a l2{ok (+) l1 l2}) (v1:raw a m1) (v2:raw a m2{ok (+) m1 m2}) : Lemma (requires (let open U32 in m1 +^ m2 = l1 +^ l2 /\ equal (u1@|u2) (coerce (v1@|v2) (l1 +^ l2)) /\ (l1 == m1 \/ l2 == m2))) (ensures (l1 = m1 /\ l2 = m2 /\ equal u1 v1 /\ equal u2 v2)) = FStar.Seq.lemma_append_inj (reveal u1) (reveal u2) (reveal v1) (reveal v2)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Vector.Base.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Vector.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Vector.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: FStar.Vector.Base.raw a l -> a
Prims.Tot
[ "total" ]
[]
[ "FStar.Vector.Base.len_t", "Prims.b2t", "Prims.op_disEquality", "FStar.UInt32.t", "FStar.UInt32.__uint_to_t", "FStar.Vector.Base.raw", "FStar.Vector.Base.op_String_Access" ]
[]
false
false
false
false
false
let head (#a: Type) (#l: len_t{l <> 0ul}) (v: raw a l) : Tot a =
v.[ 0ul ]
false
FStar.Vector.Properties.fst
FStar.Vector.Properties.tail
val tail (#a: Type) (#l: len_t{l <> 0ul}) (v: raw a l) : Tot (raw a U32.(l -^ 1ul))
val tail (#a: Type) (#l: len_t{l <> 0ul}) (v: raw a l) : Tot (raw a U32.(l -^ 1ul))
let tail (#a:Type) (#l:len_t{l <> 0ul}) (v:raw a l) : Tot (raw a U32.(l -^ 1ul)) = sub v 1ul l
{ "file_name": "ulib/FStar.Vector.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 15, "end_line": 78, "start_col": 0, "start_line": 76 }
(* Copyright 2008-2017 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.Vector.Properties open FStar.Vector.Base module S = FStar.Seq module U32 = FStar.UInt32 /// This coercion seems to be necessary in some places /// /// For example, when trying to treat a `raw a (l1 +^ l2)` /// as a `raw a (m1 +^ m2)` /// F* type inference tries matches on the head symbol of the index /// and tries to prove `l1 = m1 /\ l2 = m2` /// which is often too strong. /// This coercion is a workaround for in such cases unfold let coerce (#a:Type) (#l:len_t) (v:raw a l) (m:len_t{l == m}) : Tot (raw a m) = v /// An abbreviation that states that some binary arithmetic /// operation on len_t's respects bouns unfold let ok (op:int -> int -> int) (l1:len_t) (l2:len_t) : Type = UInt.size U32.(op (v l1) (v l2)) U32.n /// Most lemmas from FStar.Seq.Properties can just be lifted /// to vectors, although the lengths have to be bounds checked let append_inj (#a:Type) (#l1:len_t) (#l2:len_t) (#m1:len_t) (#m2:len_t) (u1:raw a l1) (u2:raw a l2{ok (+) l1 l2}) (v1:raw a m1) (v2:raw a m2{ok (+) m1 m2}) : Lemma (requires (let open U32 in m1 +^ m2 = l1 +^ l2 /\ equal (u1@|u2) (coerce (v1@|v2) (l1 +^ l2)) /\ (l1 == m1 \/ l2 == m2))) (ensures (l1 = m1 /\ l2 = m2 /\ equal u1 v1 /\ equal u2 v2)) = FStar.Seq.lemma_append_inj (reveal u1) (reveal u2) (reveal v1) (reveal v2) let head (#a:Type) (#l:len_t{l <> 0ul}) (v:raw a l) : Tot a = v.[0ul]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Vector.Base.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Vector.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Vector.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: FStar.Vector.Base.raw a l -> FStar.Vector.Base.raw a (l -^ 1ul)
Prims.Tot
[ "total" ]
[]
[ "FStar.Vector.Base.len_t", "Prims.b2t", "Prims.op_disEquality", "FStar.UInt32.t", "FStar.UInt32.__uint_to_t", "FStar.Vector.Base.raw", "FStar.Vector.Base.sub", "FStar.UInt32.op_Subtraction_Hat" ]
[]
false
false
false
false
false
let tail (#a: Type) (#l: len_t{l <> 0ul}) (v: raw a l) : Tot (raw a U32.(l -^ 1ul)) =
sub v 1ul l
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.store_state_st
val store_state_st : a: Spec.Blake2.Definitions.alg -> m: Hacl.Impl.Blake2.Core.m_spec -> Type0
let store_state_st (a: Spec.alg) (m: m_spec) = st32:state_p a M32 -> st:state_p a m -> Stack unit (requires (fun h -> live h st /\ live h st32 /\ disjoint st st32)) (ensures (fun h0 _ h1 -> modifies (loc st32) h0 h1 /\ state_v h1 st32 == state_v h0 st))
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 423, "start_col": 0, "start_line": 418 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a noextract inline_for_extraction let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a) noextract inline_for_extraction val zero_element: a:Spec.alg -> m:m_spec -> element_t a m noextract inline_for_extraction let row_len (a:Spec.alg) (m:m_spec) : size_t = match a,m with | Spec.Blake2S,M128 -> 1ul | Spec.Blake2S,M256 -> 1ul | Spec.Blake2B,M256 -> 1ul | _ -> 4ul noextract inline_for_extraction unfold let row_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (row_len a m) noextract inline_for_extraction val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) noextract val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m -> Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==> row_v h0 r1 == row_v h1 r2)) [SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)] noextract inline_for_extraction let salt_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noextract inline_for_extraction let personal_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noeq type blake2s_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint16; node_depth: uint8; inner_length: uint8; salt: lbuffer uint8 8ul; personal: lbuffer uint8 8ul; } inline_for_extraction noextract let get_blake2s_salt (p: blake2s_params) = p.salt inline_for_extraction noextract let get_blake2s_personal (p: blake2s_params) = p.personal inline_for_extraction noextract let set_blake2s_digest_length (p: blake2s_params) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S}) : blake2s_params = {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S}) : blake2s_params = {p with key_length = to_u8 kk} let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop = live h p.salt /\ live h p.personal let blake2s_params_loc (p: blake2s_params) = loc p.salt `union` loc p.personal let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params = Spec.Mkblake2s_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noeq type blake2b_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint32; node_depth: uint8; inner_length: uint8; // Blake2b also contains 14 reserved bytes here, but they seem // unused and to only contain zeros, hence we do not expose them salt: lbuffer uint8 16ul; personal: lbuffer uint8 16ul; } let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop = live h p.salt /\ live h p.personal let blake2b_params_loc (p: blake2b_params) = loc p.salt `union` loc p.personal let blake2b_params_v (h: mem) (p: blake2b_params): GTot Spec.blake2b_params = Spec.Mkblake2b_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noextract inline_for_extraction let blake2_params (a:Spec.alg) = match a with | Spec.Blake2S -> blake2s_params | Spec.Blake2B -> blake2b_params inline_for_extraction noextract let set_digest_length (#a: Spec.alg) (p: blake2_params a) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_digest_length p nn | Spec.Blake2B -> {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_key_length (#a: Spec.alg) (p: blake2_params a) (kk: size_t{v kk <= Spec.max_key a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_key_length p kk | Spec.Blake2B -> {p with key_length = to_u8 kk} inline_for_extraction noextract let get_salt (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (salt_len a) = match a with | Spec.Blake2S -> get_blake2s_salt p | Spec.Blake2B -> p.salt inline_for_extraction noextract let get_personal (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (personal_len a) = match a with | Spec.Blake2S -> get_blake2s_personal p | Spec.Blake2B -> p.personal noextract inline_for_extraction let blake2_params_inv (#a:Spec.alg) (h: mem) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_inv h p | Spec.Blake2B -> blake2b_params_inv h p noextract inline_for_extraction let blake2_params_loc (#a:Spec.alg) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_loc p | Spec.Blake2B -> blake2b_params_loc p noextract inline_for_extraction let blake2_params_v (#a:Spec.alg) (h: mem) (p: blake2_params a) : GTot (Spec.blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_v h p | Spec.Blake2B -> blake2b_params_v h p noextract inline_for_extraction val create_default_params: a:Spec.alg -> salt: lbuffer uint8 (salt_len a) -> personal: lbuffer uint8 (personal_len a) -> Stack (blake2_params a) (requires fun h -> live h salt /\ live h personal /\ as_seq h salt == Seq.create (Spec.salt_length a) (u8 0) /\ as_seq h personal == Seq.create (Spec.personal_length a) (u8 0) ) (ensures (fun h0 p h1 -> h0 == h1 /\ blake2_params_loc p == loc salt `union` loc personal /\ blake2_params_inv h1 p /\ blake2_params_v h1 p == Spec.blake2_default_params a)) noextract inline_for_extraction unfold let state_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (4ul *. row_len a m) noextract inline_for_extraction unfold let index_t = n:size_t{v n < 4} noextract inline_for_extraction let g_rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) : GTot (row_p a m) = gsub st (idx *. row_len a m) (row_len a m) val g_rowi_disjoint: #a:Spec.alg -> #m:m_spec -> st:state_p a m -> idx1:index_t -> idx2:index_t -> Lemma (ensures (v idx1 <> v idx2 ==> disjoint (g_rowi st idx1) (g_rowi st idx2))) [SMTPat (disjoint (g_rowi st idx1) (g_rowi st idx2))] val g_rowi_unchanged: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t -> Lemma (requires (as_seq h0 st == as_seq h1 st)) (ensures (as_seq h0 (g_rowi st i) == as_seq h1 (g_rowi st i))) [SMTPat (as_seq h0 (g_rowi st i)); SMTPat (as_seq h1 (g_rowi st i))] val g_rowi_disjoint_other: #a:Spec.alg -> #m:m_spec -> #b:Type -> st:state_p a m -> i:index_t -> x:buffer b -> Lemma(requires (disjoint st x)) (ensures (disjoint (g_rowi st i) x)) [SMTPat (disjoint (g_rowi st i) x)] inline_for_extraction noextract val state_v: #a:Spec.alg -> #m:m_spec -> mem -> state_p a m -> GTot (Spec.state a) noextract val state_v_eq_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> st1:state_p a m -> st2:state_p a m -> Lemma (requires (as_seq h0 st1 == as_seq h1 st2)) (ensures (state_v h0 st1 == state_v h1 st2)) [SMTPat (state_v #a #m h0 st1); SMTPat (state_v #a #m h1 st2)] noextract val state_v_rowi_lemma: #a:Spec.alg -> #m:m_spec -> h:mem -> st:state_p a m -> i:index_t -> Lemma (requires (live h st)) (ensures (Lib.Sequence.((state_v h st).[v i] == row_v h (g_rowi st i)))) [SMTPat (row_v h (g_rowi st i))] noextract val state_v_live_rowi_lemma: #a:Spec.alg -> #m:m_spec -> h:mem -> st:state_p a m -> i:index_t -> Lemma (requires (live h st)) (ensures (live h (g_rowi st i))) [SMTPat (live h (g_rowi st i))] noextract val modifies_one_row: a:Spec.alg -> m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t -> j:index_t -> Lemma (requires (live h0 st /\ modifies (loc (g_rowi st i)) h0 h1 /\ v i <> v j)) (ensures (row_v h1 (g_rowi st j) == row_v h0 (g_rowi st j))) [SMTPat (modifies (loc (g_rowi st i)) h0 h1); SMTPat (row_v h1 (g_rowi st j))] noextract val modifies_row_state: a:Spec.alg -> m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t -> Lemma (requires (live h0 st /\ modifies (loc (g_rowi st i)) h0 h1)) (ensures (modifies (loc st) h0 h1 /\ state_v h1 st == Lib.Sequence.((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))) [SMTPat (modifies (loc (g_rowi #a #m st i)) h0 h1)] noextract inline_for_extraction val rowi: #a:Spec.alg -> #m:m_spec -> st:state_p a m -> idx:index_t -> Stack (row_p a m) (requires (fun h -> live h st)) (ensures (fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == g_rowi st idx)) noextract inline_for_extraction val xor_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:row_p a m -> Stack unit (requires (fun h -> live h r1 /\ live h r2 /\ disjoint r1 r2)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( row_v h0 r1 ^| row_v h0 r2 ))) noextract inline_for_extraction val add_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:row_p a m -> Stack unit (requires (fun h -> live h r1 /\ live h r2 /\ disjoint r1 r2)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( row_v h0 r1 +| row_v h0 r2 ))) noextract inline_for_extraction val ror_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:rotval (Spec.wt a) -> Stack unit (requires (fun h -> live h r1)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( row_v h0 r1 >>>| r2 ))) noextract inline_for_extraction val permr_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> n:index_t -> Stack unit (requires (fun h -> live h r1)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( rotr (row_v h0 r1) (v n) ))) val create4_lemma: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a -> Lemma (ensures ( let l = [ x0; x1; x2; x3 ] in assert_norm (List.Tot.length l = 4); Lib.Sequence.createL l == Lib.Sequence.create4 x0 x1 x2 x3)) [SMTPat (Lib.Sequence.createL [x0;x1;x2;x3])] noextract inline_for_extraction val alloc_row: a:Spec.alg -> m:m_spec -> StackInline (row_p a m) (requires (fun h -> True)) (ensures (fun h0 r h1 -> stack_allocated r h0 h1 (Lib.Sequence.create (v (row_len a m)) (zero_element a m)) /\ live h1 r /\ row_v h1 r == Spec.zero_row a)) noextract inline_for_extraction val create_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> w0:word_t a -> w1:word_t a -> w2:word_t a -> w3:word_t a -> Stack unit (requires (fun h -> live h r1)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( create_row w0 w1 w2 w3 ))) noextract inline_for_extraction val load_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> ws:lbuffer (word_t a) 4ul -> Stack unit (requires (fun h -> live h r1 /\ live h ws /\ disjoint r1 ws)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( load_row (as_seq h0 ws)))) noextract inline_for_extraction let size_row al = 4ul *. size (Spec.size_word al) noextract inline_for_extraction val store_row: #a:Spec.alg -> #m:m_spec -> b:lbuffer uint8 (size_row a) -> r:row_p a m -> Stack unit (requires (fun h -> live h r /\ live h b /\ disjoint r b)) (ensures (fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Lib.ByteSequence.uints_to_bytes_le (row_v h0 r))) noextract inline_for_extraction val store_row32: #a:Spec.alg -> #m:m_spec -> b:lbuffer (word_t a) 4ul -> r:row_p a m -> Stack unit (requires (fun h -> live h r /\ live h b /\ disjoint r b)) (ensures (fun h0 _ h1 -> modifies (loc b) h0 h1 /\ Spec.( load_row (as_seq h1 b)) == row_v h0 r)) noextract inline_for_extraction let size_block (a:Spec.alg) : x:size_t{v x = 16 * Spec.size_word a} = Spec.alg_inversion_lemma a; match a with | Spec.Blake2.Blake2S -> 64ul | Spec.Blake2.Blake2B -> 128ul noextract inline_for_extraction type block_p (a:Spec.alg) = lbuffer uint8 (size_block a) noextract inline_for_extraction type block_w (a:Spec.alg) = lbuffer (word_t a) 16ul noextract inline_for_extraction val gather_row: #a:Spec.alg -> #ms:m_spec -> r:row_p a ms -> m:block_w a -> i0: Spec.sigma_elt_t -> i1:Spec.sigma_elt_t -> i2:Spec.sigma_elt_t -> i3:Spec.sigma_elt_t -> Stack unit (requires (fun h -> live h r /\ live h m /\ disjoint r m)) (ensures (fun h0 _ h1 -> modifies (loc r) h0 h1 /\ row_v h1 r == Spec.(gather_row (as_seq h0 m) i0 i1 i2 i3))) noextract inline_for_extraction val le_sigh (a:Spec.alg) (m:m_spec): x:size_t { x == 4ul *. row_len a m } noextract inline_for_extraction val alloc_state: a:Spec.alg -> m:m_spec -> StackInline (state_p a m) (requires (fun h -> True)) (ensures (fun h0 r h1 -> stack_allocated r h0 h1 (Lib.Sequence.create (4 * v (row_len a m)) (zero_element a m)) /\ live h1 r)) noextract inline_for_extraction val copy_state: #a:Spec.alg -> #m:m_spec -> st2:state_p a m -> st1:state_p a m -> Stack unit (requires (fun h0 -> live h0 st1 /\ live h0 st2 /\ disjoint st1 st2)) (ensures (fun h0 r h1 -> modifies (loc st2) h0 h1 /\ state_v h1 st2 == state_v h0 st1)) noextract inline_for_extraction let load_state_st (a: Spec.alg) (m: m_spec) = st:state_p a m -> st32:state_p a M32 -> Stack unit (requires (fun h -> live h st /\ live h st32 /\ disjoint st st32)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ state_v h1 st == state_v h0 st32)) noextract inline_for_extraction val load_state_from_state32: #a:Spec.alg -> #m:m_spec -> load_state_st a m
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Blake2.Definitions.alg -> m: Hacl.Impl.Blake2.Core.m_spec -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "Hacl.Impl.Blake2.Core.m_spec", "Hacl.Impl.Blake2.Core.state_p", "Hacl.Impl.Blake2.Core.M32", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Impl.Blake2.Core.element_t", "Lib.Buffer.disjoint", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Spec.Blake2.Definitions.state", "Hacl.Impl.Blake2.Core.state_v" ]
[]
false
false
false
true
true
let store_state_st (a: Spec.alg) (m: m_spec) =
st32: state_p a M32 -> st: state_p a m -> Stack unit (requires (fun h -> live h st /\ live h st32 /\ disjoint st st32)) (ensures (fun h0 _ h1 -> modifies (loc st32) h0 h1 /\ state_v h1 st32 == state_v h0 st))
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.load_state_st
val load_state_st : a: Spec.Blake2.Definitions.alg -> m: Hacl.Impl.Blake2.Core.m_spec -> Type0
let load_state_st (a: Spec.alg) (m: m_spec) = st:state_p a m -> st32:state_p a M32 -> Stack unit (requires (fun h -> live h st /\ live h st32 /\ disjoint st st32)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ state_v h1 st == state_v h0 st32))
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 412, "start_col": 0, "start_line": 407 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a noextract inline_for_extraction let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a) noextract inline_for_extraction val zero_element: a:Spec.alg -> m:m_spec -> element_t a m noextract inline_for_extraction let row_len (a:Spec.alg) (m:m_spec) : size_t = match a,m with | Spec.Blake2S,M128 -> 1ul | Spec.Blake2S,M256 -> 1ul | Spec.Blake2B,M256 -> 1ul | _ -> 4ul noextract inline_for_extraction unfold let row_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (row_len a m) noextract inline_for_extraction val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) noextract val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m -> Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==> row_v h0 r1 == row_v h1 r2)) [SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)] noextract inline_for_extraction let salt_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noextract inline_for_extraction let personal_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noeq type blake2s_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint16; node_depth: uint8; inner_length: uint8; salt: lbuffer uint8 8ul; personal: lbuffer uint8 8ul; } inline_for_extraction noextract let get_blake2s_salt (p: blake2s_params) = p.salt inline_for_extraction noextract let get_blake2s_personal (p: blake2s_params) = p.personal inline_for_extraction noextract let set_blake2s_digest_length (p: blake2s_params) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S}) : blake2s_params = {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S}) : blake2s_params = {p with key_length = to_u8 kk} let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop = live h p.salt /\ live h p.personal let blake2s_params_loc (p: blake2s_params) = loc p.salt `union` loc p.personal let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params = Spec.Mkblake2s_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noeq type blake2b_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint32; node_depth: uint8; inner_length: uint8; // Blake2b also contains 14 reserved bytes here, but they seem // unused and to only contain zeros, hence we do not expose them salt: lbuffer uint8 16ul; personal: lbuffer uint8 16ul; } let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop = live h p.salt /\ live h p.personal let blake2b_params_loc (p: blake2b_params) = loc p.salt `union` loc p.personal let blake2b_params_v (h: mem) (p: blake2b_params): GTot Spec.blake2b_params = Spec.Mkblake2b_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noextract inline_for_extraction let blake2_params (a:Spec.alg) = match a with | Spec.Blake2S -> blake2s_params | Spec.Blake2B -> blake2b_params inline_for_extraction noextract let set_digest_length (#a: Spec.alg) (p: blake2_params a) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_digest_length p nn | Spec.Blake2B -> {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_key_length (#a: Spec.alg) (p: blake2_params a) (kk: size_t{v kk <= Spec.max_key a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_key_length p kk | Spec.Blake2B -> {p with key_length = to_u8 kk} inline_for_extraction noextract let get_salt (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (salt_len a) = match a with | Spec.Blake2S -> get_blake2s_salt p | Spec.Blake2B -> p.salt inline_for_extraction noextract let get_personal (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (personal_len a) = match a with | Spec.Blake2S -> get_blake2s_personal p | Spec.Blake2B -> p.personal noextract inline_for_extraction let blake2_params_inv (#a:Spec.alg) (h: mem) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_inv h p | Spec.Blake2B -> blake2b_params_inv h p noextract inline_for_extraction let blake2_params_loc (#a:Spec.alg) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_loc p | Spec.Blake2B -> blake2b_params_loc p noextract inline_for_extraction let blake2_params_v (#a:Spec.alg) (h: mem) (p: blake2_params a) : GTot (Spec.blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_v h p | Spec.Blake2B -> blake2b_params_v h p noextract inline_for_extraction val create_default_params: a:Spec.alg -> salt: lbuffer uint8 (salt_len a) -> personal: lbuffer uint8 (personal_len a) -> Stack (blake2_params a) (requires fun h -> live h salt /\ live h personal /\ as_seq h salt == Seq.create (Spec.salt_length a) (u8 0) /\ as_seq h personal == Seq.create (Spec.personal_length a) (u8 0) ) (ensures (fun h0 p h1 -> h0 == h1 /\ blake2_params_loc p == loc salt `union` loc personal /\ blake2_params_inv h1 p /\ blake2_params_v h1 p == Spec.blake2_default_params a)) noextract inline_for_extraction unfold let state_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (4ul *. row_len a m) noextract inline_for_extraction unfold let index_t = n:size_t{v n < 4} noextract inline_for_extraction let g_rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) : GTot (row_p a m) = gsub st (idx *. row_len a m) (row_len a m) val g_rowi_disjoint: #a:Spec.alg -> #m:m_spec -> st:state_p a m -> idx1:index_t -> idx2:index_t -> Lemma (ensures (v idx1 <> v idx2 ==> disjoint (g_rowi st idx1) (g_rowi st idx2))) [SMTPat (disjoint (g_rowi st idx1) (g_rowi st idx2))] val g_rowi_unchanged: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t -> Lemma (requires (as_seq h0 st == as_seq h1 st)) (ensures (as_seq h0 (g_rowi st i) == as_seq h1 (g_rowi st i))) [SMTPat (as_seq h0 (g_rowi st i)); SMTPat (as_seq h1 (g_rowi st i))] val g_rowi_disjoint_other: #a:Spec.alg -> #m:m_spec -> #b:Type -> st:state_p a m -> i:index_t -> x:buffer b -> Lemma(requires (disjoint st x)) (ensures (disjoint (g_rowi st i) x)) [SMTPat (disjoint (g_rowi st i) x)] inline_for_extraction noextract val state_v: #a:Spec.alg -> #m:m_spec -> mem -> state_p a m -> GTot (Spec.state a) noextract val state_v_eq_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> st1:state_p a m -> st2:state_p a m -> Lemma (requires (as_seq h0 st1 == as_seq h1 st2)) (ensures (state_v h0 st1 == state_v h1 st2)) [SMTPat (state_v #a #m h0 st1); SMTPat (state_v #a #m h1 st2)] noextract val state_v_rowi_lemma: #a:Spec.alg -> #m:m_spec -> h:mem -> st:state_p a m -> i:index_t -> Lemma (requires (live h st)) (ensures (Lib.Sequence.((state_v h st).[v i] == row_v h (g_rowi st i)))) [SMTPat (row_v h (g_rowi st i))] noextract val state_v_live_rowi_lemma: #a:Spec.alg -> #m:m_spec -> h:mem -> st:state_p a m -> i:index_t -> Lemma (requires (live h st)) (ensures (live h (g_rowi st i))) [SMTPat (live h (g_rowi st i))] noextract val modifies_one_row: a:Spec.alg -> m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t -> j:index_t -> Lemma (requires (live h0 st /\ modifies (loc (g_rowi st i)) h0 h1 /\ v i <> v j)) (ensures (row_v h1 (g_rowi st j) == row_v h0 (g_rowi st j))) [SMTPat (modifies (loc (g_rowi st i)) h0 h1); SMTPat (row_v h1 (g_rowi st j))] noextract val modifies_row_state: a:Spec.alg -> m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t -> Lemma (requires (live h0 st /\ modifies (loc (g_rowi st i)) h0 h1)) (ensures (modifies (loc st) h0 h1 /\ state_v h1 st == Lib.Sequence.((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))) [SMTPat (modifies (loc (g_rowi #a #m st i)) h0 h1)] noextract inline_for_extraction val rowi: #a:Spec.alg -> #m:m_spec -> st:state_p a m -> idx:index_t -> Stack (row_p a m) (requires (fun h -> live h st)) (ensures (fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == g_rowi st idx)) noextract inline_for_extraction val xor_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:row_p a m -> Stack unit (requires (fun h -> live h r1 /\ live h r2 /\ disjoint r1 r2)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( row_v h0 r1 ^| row_v h0 r2 ))) noextract inline_for_extraction val add_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:row_p a m -> Stack unit (requires (fun h -> live h r1 /\ live h r2 /\ disjoint r1 r2)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( row_v h0 r1 +| row_v h0 r2 ))) noextract inline_for_extraction val ror_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:rotval (Spec.wt a) -> Stack unit (requires (fun h -> live h r1)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( row_v h0 r1 >>>| r2 ))) noextract inline_for_extraction val permr_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> n:index_t -> Stack unit (requires (fun h -> live h r1)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( rotr (row_v h0 r1) (v n) ))) val create4_lemma: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a -> Lemma (ensures ( let l = [ x0; x1; x2; x3 ] in assert_norm (List.Tot.length l = 4); Lib.Sequence.createL l == Lib.Sequence.create4 x0 x1 x2 x3)) [SMTPat (Lib.Sequence.createL [x0;x1;x2;x3])] noextract inline_for_extraction val alloc_row: a:Spec.alg -> m:m_spec -> StackInline (row_p a m) (requires (fun h -> True)) (ensures (fun h0 r h1 -> stack_allocated r h0 h1 (Lib.Sequence.create (v (row_len a m)) (zero_element a m)) /\ live h1 r /\ row_v h1 r == Spec.zero_row a)) noextract inline_for_extraction val create_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> w0:word_t a -> w1:word_t a -> w2:word_t a -> w3:word_t a -> Stack unit (requires (fun h -> live h r1)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( create_row w0 w1 w2 w3 ))) noextract inline_for_extraction val load_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> ws:lbuffer (word_t a) 4ul -> Stack unit (requires (fun h -> live h r1 /\ live h ws /\ disjoint r1 ws)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( load_row (as_seq h0 ws)))) noextract inline_for_extraction let size_row al = 4ul *. size (Spec.size_word al) noextract inline_for_extraction val store_row: #a:Spec.alg -> #m:m_spec -> b:lbuffer uint8 (size_row a) -> r:row_p a m -> Stack unit (requires (fun h -> live h r /\ live h b /\ disjoint r b)) (ensures (fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Lib.ByteSequence.uints_to_bytes_le (row_v h0 r))) noextract inline_for_extraction val store_row32: #a:Spec.alg -> #m:m_spec -> b:lbuffer (word_t a) 4ul -> r:row_p a m -> Stack unit (requires (fun h -> live h r /\ live h b /\ disjoint r b)) (ensures (fun h0 _ h1 -> modifies (loc b) h0 h1 /\ Spec.( load_row (as_seq h1 b)) == row_v h0 r)) noextract inline_for_extraction let size_block (a:Spec.alg) : x:size_t{v x = 16 * Spec.size_word a} = Spec.alg_inversion_lemma a; match a with | Spec.Blake2.Blake2S -> 64ul | Spec.Blake2.Blake2B -> 128ul noextract inline_for_extraction type block_p (a:Spec.alg) = lbuffer uint8 (size_block a) noextract inline_for_extraction type block_w (a:Spec.alg) = lbuffer (word_t a) 16ul noextract inline_for_extraction val gather_row: #a:Spec.alg -> #ms:m_spec -> r:row_p a ms -> m:block_w a -> i0: Spec.sigma_elt_t -> i1:Spec.sigma_elt_t -> i2:Spec.sigma_elt_t -> i3:Spec.sigma_elt_t -> Stack unit (requires (fun h -> live h r /\ live h m /\ disjoint r m)) (ensures (fun h0 _ h1 -> modifies (loc r) h0 h1 /\ row_v h1 r == Spec.(gather_row (as_seq h0 m) i0 i1 i2 i3))) noextract inline_for_extraction val le_sigh (a:Spec.alg) (m:m_spec): x:size_t { x == 4ul *. row_len a m } noextract inline_for_extraction val alloc_state: a:Spec.alg -> m:m_spec -> StackInline (state_p a m) (requires (fun h -> True)) (ensures (fun h0 r h1 -> stack_allocated r h0 h1 (Lib.Sequence.create (4 * v (row_len a m)) (zero_element a m)) /\ live h1 r)) noextract inline_for_extraction val copy_state: #a:Spec.alg -> #m:m_spec -> st2:state_p a m -> st1:state_p a m -> Stack unit (requires (fun h0 -> live h0 st1 /\ live h0 st2 /\ disjoint st1 st2)) (ensures (fun h0 r h1 -> modifies (loc st2) h0 h1 /\ state_v h1 st2 == state_v h0 st1))
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Blake2.Definitions.alg -> m: Hacl.Impl.Blake2.Core.m_spec -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "Hacl.Impl.Blake2.Core.m_spec", "Hacl.Impl.Blake2.Core.state_p", "Hacl.Impl.Blake2.Core.M32", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Impl.Blake2.Core.element_t", "Lib.Buffer.disjoint", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Spec.Blake2.Definitions.state", "Hacl.Impl.Blake2.Core.state_v" ]
[]
false
false
false
true
true
let load_state_st (a: Spec.alg) (m: m_spec) =
st: state_p a m -> st32: state_p a M32 -> Stack unit (requires (fun h -> live h st /\ live h st32 /\ disjoint st st32)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ state_v h1 st == state_v h0 st32))
false
FStar.Vector.Properties.fst
FStar.Vector.Properties.append_inj
val append_inj (#a: Type) (#l1 #l2 #m1 #m2: len_t) (u1: raw a l1) (u2: raw a l2 {ok ( + ) l1 l2}) (v1: raw a m1) (v2: raw a m2 {ok ( + ) m1 m2}) : Lemma (requires (let open U32 in m1 +^ m2 = l1 +^ l2 /\ equal (u1 @| u2) (coerce (v1 @| v2) (l1 +^ l2)) /\ (l1 == m1 \/ l2 == m2))) (ensures (l1 = m1 /\ l2 = m2 /\ equal u1 v1 /\ equal u2 v2))
val append_inj (#a: Type) (#l1 #l2 #m1 #m2: len_t) (u1: raw a l1) (u2: raw a l2 {ok ( + ) l1 l2}) (v1: raw a m1) (v2: raw a m2 {ok ( + ) m1 m2}) : Lemma (requires (let open U32 in m1 +^ m2 = l1 +^ l2 /\ equal (u1 @| u2) (coerce (v1 @| v2) (l1 +^ l2)) /\ (l1 == m1 \/ l2 == m2))) (ensures (l1 = m1 /\ l2 = m2 /\ equal u1 v1 /\ equal u2 v2))
let append_inj (#a:Type) (#l1:len_t) (#l2:len_t) (#m1:len_t) (#m2:len_t) (u1:raw a l1) (u2:raw a l2{ok (+) l1 l2}) (v1:raw a m1) (v2:raw a m2{ok (+) m1 m2}) : Lemma (requires (let open U32 in m1 +^ m2 = l1 +^ l2 /\ equal (u1@|u2) (coerce (v1@|v2) (l1 +^ l2)) /\ (l1 == m1 \/ l2 == m2))) (ensures (l1 = m1 /\ l2 = m2 /\ equal u1 v1 /\ equal u2 v2)) = FStar.Seq.lemma_append_inj (reveal u1) (reveal u2) (reveal v1) (reveal v2)
{ "file_name": "ulib/FStar.Vector.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 78, "end_line": 70, "start_col": 0, "start_line": 51 }
(* Copyright 2008-2017 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.Vector.Properties open FStar.Vector.Base module S = FStar.Seq module U32 = FStar.UInt32 /// This coercion seems to be necessary in some places /// /// For example, when trying to treat a `raw a (l1 +^ l2)` /// as a `raw a (m1 +^ m2)` /// F* type inference tries matches on the head symbol of the index /// and tries to prove `l1 = m1 /\ l2 = m2` /// which is often too strong. /// This coercion is a workaround for in such cases unfold let coerce (#a:Type) (#l:len_t) (v:raw a l) (m:len_t{l == m}) : Tot (raw a m) = v /// An abbreviation that states that some binary arithmetic /// operation on len_t's respects bouns unfold let ok (op:int -> int -> int) (l1:len_t) (l2:len_t) : Type = UInt.size U32.(op (v l1) (v l2)) U32.n /// Most lemmas from FStar.Seq.Properties can just be lifted
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Vector.Base.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Vector.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Vector.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
u1: FStar.Vector.Base.raw a l1 -> u2: FStar.Vector.Base.raw a l2 {FStar.Vector.Properties.ok Prims.op_Addition l1 l2} -> v1: FStar.Vector.Base.raw a m1 -> v2: FStar.Vector.Base.raw a m2 {FStar.Vector.Properties.ok Prims.op_Addition m1 m2} -> FStar.Pervasives.Lemma (requires m1 +^ m2 = l1 +^ l2 /\ FStar.Vector.Base.equal (u1 @| u2) (FStar.Vector.Properties.coerce (v1 @| v2) (l1 +^ l2)) /\ (l1 == m1 \/ l2 == m2)) (ensures l1 = m1 /\ l2 = m2 /\ FStar.Vector.Base.equal u1 v1 /\ FStar.Vector.Base.equal u2 v2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Vector.Base.len_t", "FStar.Vector.Base.raw", "FStar.Vector.Properties.ok", "Prims.op_Addition", "FStar.Seq.Properties.lemma_append_inj", "FStar.Vector.Base.reveal", "Prims.unit", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "FStar.UInt32.t", "FStar.UInt32.op_Plus_Hat", "FStar.Vector.Base.equal", "FStar.UInt32.add", "FStar.Vector.Base.op_At_Bar", "FStar.Vector.Properties.coerce", "Prims.l_or", "Prims.eq2", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let append_inj (#a: Type) (#l1 #l2 #m1 #m2: len_t) (u1: raw a l1) (u2: raw a l2 {ok ( + ) l1 l2}) (v1: raw a m1) (v2: raw a m2 {ok ( + ) m1 m2}) : Lemma (requires (let open U32 in m1 +^ m2 = l1 +^ l2 /\ equal (u1 @| u2) (coerce (v1 @| v2) (l1 +^ l2)) /\ (l1 == m1 \/ l2 == m2))) (ensures (l1 = m1 /\ l2 = m2 /\ equal u1 v1 /\ equal u2 v2)) =
FStar.Seq.lemma_append_inj (reveal u1) (reveal u2) (reveal v1) (reveal v2)
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.term_eq
val term_eq : _: FStar.Stubs.Reflection.Types.term -> _: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.bool
let term_eq = FStar.Tactics.term_eq_old
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 25, "start_col": 0, "start_line": 25 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: FStar.Stubs.Reflection.Types.term -> _: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.bool
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Tactics.V1.Builtins.term_eq_old" ]
[]
false
true
false
false
false
let term_eq =
FStar.Tactics.term_eq_old
false
FStar.Vector.Properties.fst
FStar.Vector.Properties.tail_append
val tail_append (#a: Type) (#l1 #l2: len_t) (v1: raw a l1 {l1 <> 0ul}) (v2: raw a l2 {ok ( + ) l1 l2}) : Lemma (ensures (tail (v1 @| v2) == tail v1 @| v2))
val tail_append (#a: Type) (#l1 #l2: len_t) (v1: raw a l1 {l1 <> 0ul}) (v2: raw a l2 {ok ( + ) l1 l2}) : Lemma (ensures (tail (v1 @| v2) == tail v1 @| v2))
let tail_append (#a:Type) (#l1:len_t) (#l2:len_t) (v1:raw a l1{l1 <> 0ul}) (v2:raw a l2{ok (+) l1 l2}) : Lemma (ensures (tail (v1@|v2) == tail v1@|v2)) = Seq.lemma_tail_append (reveal v1) (reveal v2)
{ "file_name": "ulib/FStar.Vector.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 98, "start_col": 0, "start_line": 90 }
(* Copyright 2008-2017 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.Vector.Properties open FStar.Vector.Base module S = FStar.Seq module U32 = FStar.UInt32 /// This coercion seems to be necessary in some places /// /// For example, when trying to treat a `raw a (l1 +^ l2)` /// as a `raw a (m1 +^ m2)` /// F* type inference tries matches on the head symbol of the index /// and tries to prove `l1 = m1 /\ l2 = m2` /// which is often too strong. /// This coercion is a workaround for in such cases unfold let coerce (#a:Type) (#l:len_t) (v:raw a l) (m:len_t{l == m}) : Tot (raw a m) = v /// An abbreviation that states that some binary arithmetic /// operation on len_t's respects bouns unfold let ok (op:int -> int -> int) (l1:len_t) (l2:len_t) : Type = UInt.size U32.(op (v l1) (v l2)) U32.n /// Most lemmas from FStar.Seq.Properties can just be lifted /// to vectors, although the lengths have to be bounds checked let append_inj (#a:Type) (#l1:len_t) (#l2:len_t) (#m1:len_t) (#m2:len_t) (u1:raw a l1) (u2:raw a l2{ok (+) l1 l2}) (v1:raw a m1) (v2:raw a m2{ok (+) m1 m2}) : Lemma (requires (let open U32 in m1 +^ m2 = l1 +^ l2 /\ equal (u1@|u2) (coerce (v1@|v2) (l1 +^ l2)) /\ (l1 == m1 \/ l2 == m2))) (ensures (l1 = m1 /\ l2 = m2 /\ equal u1 v1 /\ equal u2 v2)) = FStar.Seq.lemma_append_inj (reveal u1) (reveal u2) (reveal v1) (reveal v2) let head (#a:Type) (#l:len_t{l <> 0ul}) (v:raw a l) : Tot a = v.[0ul] let tail (#a:Type) (#l:len_t{l <> 0ul}) (v:raw a l) : Tot (raw a U32.(l -^ 1ul)) = sub v 1ul l let head_append (#a:Type) (#l1:len_t) (#l2:len_t) (v1:raw a l1{l1 <> 0ul}) (v2:raw a l2{ok (+) l1 l2}) : Lemma (ensures (head (v1@|v2) == head v1)) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Vector.Base.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Vector.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Vector.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
v1: FStar.Vector.Base.raw a l1 {l1 <> 0ul} -> v2: FStar.Vector.Base.raw a l2 {FStar.Vector.Properties.ok Prims.op_Addition l1 l2} -> FStar.Pervasives.Lemma (ensures FStar.Vector.Properties.tail (v1 @| v2) == FStar.Vector.Properties.tail v1 @| v2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Vector.Base.len_t", "FStar.Vector.Base.raw", "Prims.b2t", "Prims.op_disEquality", "FStar.UInt32.t", "FStar.UInt32.__uint_to_t", "FStar.Vector.Properties.ok", "Prims.op_Addition", "FStar.Seq.Properties.lemma_tail_append", "FStar.Vector.Base.reveal", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.UInt32.op_Subtraction_Hat", "FStar.UInt32.add", "FStar.Vector.Properties.tail", "FStar.Vector.Base.op_At_Bar", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let tail_append (#a: Type) (#l1 #l2: len_t) (v1: raw a l1 {l1 <> 0ul}) (v2: raw a l2 {ok ( + ) l1 l2}) : Lemma (ensures (tail (v1 @| v2) == tail v1 @| v2)) =
Seq.lemma_tail_append (reveal v1) (reveal v2)
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.const
val const (#a: Type) (xa: a) : amap a
val const (#a: Type) (xa: a) : amap a
let const (#a:Type) (xa:a) : amap a = ([], xa)
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 46, "end_line": 61, "start_col": 0, "start_line": 61 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
xa: a -> FStar.Tactics.CanonCommMonoidSimple.amap a
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.Mktuple2", "Prims.list", "FStar.Pervasives.Native.tuple2", "FStar.Tactics.CanonCommMonoidSimple.atom", "Prims.Nil", "FStar.Tactics.CanonCommMonoidSimple.amap" ]
[]
false
false
false
true
false
let const (#a: Type) (xa: a) : amap a =
([], xa)
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.amap
val amap : a: Type -> Type
let amap (a:Type) = list (atom * a) * a
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 60, "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.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> Type
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple2", "Prims.list", "FStar.Tactics.CanonCommMonoidSimple.atom" ]
[]
false
false
false
true
true
let amap (a: Type) =
list (atom * a) * a
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.dump
val dump : m: Prims.string -> FStar.Tactics.Effect.Tac Prims.unit
let dump m = if debugging () then dump m
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "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.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: Prims.string -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.string", "FStar.Stubs.Tactics.V2.Builtins.dump", "Prims.unit", "Prims.bool", "FStar.Stubs.Tactics.V2.Builtins.debugging" ]
[]
false
true
false
false
false
let dump m =
if debugging () then dump m
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.update
val update (#a: Type) (x: atom) (xa: a) (am: amap a) : amap a
val update (#a: Type) (x: atom) (xa: a) (am: amap a) : amap a
let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 67, "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.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Tactics.CanonCommMonoidSimple.atom -> xa: a -> am: FStar.Tactics.CanonCommMonoidSimple.amap a -> FStar.Tactics.CanonCommMonoidSimple.amap a
Prims.Tot
[ "total" ]
[]
[ "FStar.Tactics.CanonCommMonoidSimple.atom", "FStar.Tactics.CanonCommMonoidSimple.amap", "FStar.Pervasives.Native.Mktuple2", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.Cons", "FStar.Pervasives.Native.fst", "FStar.Pervasives.Native.snd" ]
[]
false
false
false
true
false
let update (#a: Type) (x: atom) (xa: a) (am: amap a) : amap a =
(x, xa) :: fst am, snd am
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.select
val select (#a: Type) (x: atom) (am: amap a) : Tot a
val select (#a: Type) (x: atom) (am: amap a) : Tot a
let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 15, "end_line": 65, "start_col": 0, "start_line": 62 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Tactics.CanonCommMonoidSimple.atom -> am: FStar.Tactics.CanonCommMonoidSimple.amap a -> a
Prims.Tot
[ "total" ]
[]
[ "FStar.Tactics.CanonCommMonoidSimple.atom", "FStar.Tactics.CanonCommMonoidSimple.amap", "FStar.List.Tot.Base.assoc", "FStar.Pervasives.Native.fst", "Prims.list", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.snd" ]
[]
false
false
false
true
false
let select (#a: Type) (x: atom) (am: amap a) : Tot a =
match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am
false
CQueue.fst
CQueue.intro_vpure
val intro_vpure (#opened: _) (p: prop) : SteelGhost unit opened emp (fun _ -> vpure p) (fun _ -> p) (fun _ _ h' -> p)
val intro_vpure (#opened: _) (p: prop) : SteelGhost unit opened emp (fun _ -> vpure p) (fun _ -> p) (fun _ _ h' -> p)
let intro_vpure (#opened: _) (p: prop) : SteelGhost unit opened emp (fun _ -> vpure p) (fun _ -> p) (fun _ _ h' -> p) = change_slprop_rel emp (vpure p) (fun _ _ -> p) (fun m -> pure_interp p m)
{ "file_name": "share/steel/examples/steel/CQueue.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 120, "start_col": 0, "start_line": 107 }
module CQueue open CQueue.LList #set-options "--ide_id_info_off" //Re-define squash, since this module explicitly //replies on proving equalities of the form `t_of v == squash p` //which are delicate in the presence of optimizations that //unfold `Prims.squash (p /\ q)`to _:unit{p /\ q} //See Issue #2496 let squash (p:Type u#a) : Type0 = squash p (* BEGIN library *) let intro_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: (t_of v) -> GTot t) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v)) = intro_vrewrite v f let elim_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened (vrewrite v f) (fun _ -> v) (fun _ -> True) (fun h _ h' -> h (vrewrite v f) == f (h' v)) = elim_vrewrite v f let vconst_sel (#a: Type) (x: a) : Tot (selector a (hp_of emp)) = fun _ -> x [@@ __steel_reduce__] let vconst' (#a: Type) (x: a) : GTot vprop' = { hp = hp_of emp; t = a; sel = vconst_sel x; } [@@ __steel_reduce__] let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x) let intro_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened emp (fun _ -> vconst x) (fun _ -> True) (fun _ _ h' -> h' (vconst x) == x) = change_slprop_rel emp (vconst x) (fun _ y -> y == x) (fun _ -> ()) let elim_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened (vconst x) (fun _ -> emp) (fun _ -> True) (fun h _ _ -> h (vconst x) == x) = change_slprop_rel (vconst x) emp (fun y _ -> y == x) (fun _ -> ()) let vpure_sel' (p: prop) : Tot (selector' (squash p) (Steel.Memory.pure p)) = fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m let vpure_sel (p: prop) : Tot (selector (squash p) (Steel.Memory.pure p)) = vpure_sel' p [@@ __steel_reduce__] let vpure' (p: prop) : GTot vprop' = { hp = Steel.Memory.pure p; t = squash p; sel = vpure_sel p; } [@@ __steel_reduce__] let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "CQueue.LList.fsti.checked" ], "interface_file": true, "source_file": "CQueue.fst" }
[ { "abbrev": false, "full_module": "CQueue.LList", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Prims.prop -> Steel.Effect.Atomic.SteelGhost Prims.unit
Steel.Effect.Atomic.SteelGhost
[]
[]
[ "Steel.Memory.inames", "Prims.prop", "Steel.Effect.Atomic.change_slprop_rel", "Steel.Effect.Common.emp", "CQueue.vpure", "Steel.Effect.Common.normal", "Steel.Effect.Common.t_of", "Steel.Memory.mem", "Steel.Memory.pure_interp", "Prims.unit", "Steel.Effect.Common.vprop", "Steel.Effect.Common.rmem" ]
[]
false
true
false
false
false
let intro_vpure (#opened: _) (p: prop) : SteelGhost unit opened emp (fun _ -> vpure p) (fun _ -> p) (fun _ _ h' -> p) =
change_slprop_rel emp (vpure p) (fun _ _ -> p) (fun m -> pure_interp p m)
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.personal_len
val personal_len (a: Spec.alg) : size_t
val personal_len (a: Spec.alg) : size_t
let personal_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 66, "start_col": 0, "start_line": 63 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a noextract inline_for_extraction let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a) noextract inline_for_extraction val zero_element: a:Spec.alg -> m:m_spec -> element_t a m noextract inline_for_extraction let row_len (a:Spec.alg) (m:m_spec) : size_t = match a,m with | Spec.Blake2S,M128 -> 1ul | Spec.Blake2S,M256 -> 1ul | Spec.Blake2B,M256 -> 1ul | _ -> 4ul noextract inline_for_extraction unfold let row_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (row_len a m) noextract inline_for_extraction val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) noextract val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m -> Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==> row_v h0 r1 == row_v h1 r2)) [SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)] noextract inline_for_extraction let salt_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Blake2.Definitions.alg -> Lib.IntTypes.size_t
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t" ]
[]
false
false
false
true
false
let personal_len (a: Spec.alg) : size_t =
match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.permute
val permute : Type0
let permute = list atom -> list atom
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 36, "end_line": 109, "start_col": 0, "start_line": 109 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "FStar.Tactics.CanonCommMonoidSimple.atom" ]
[]
false
false
false
true
true
let permute =
list atom -> list atom
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.blake2_params_v
val blake2_params_v (#a: Spec.alg) (h: mem) (p: blake2_params a) : GTot (Spec.blake2_params a)
val blake2_params_v (#a: Spec.alg) (h: mem) (p: blake2_params a) : GTot (Spec.blake2_params a)
let blake2_params_v (#a:Spec.alg) (h: mem) (p: blake2_params a) : GTot (Spec.blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_v h p | Spec.Blake2B -> blake2b_params_v h p
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 40, "end_line": 212, "start_col": 0, "start_line": 209 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a noextract inline_for_extraction let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a) noextract inline_for_extraction val zero_element: a:Spec.alg -> m:m_spec -> element_t a m noextract inline_for_extraction let row_len (a:Spec.alg) (m:m_spec) : size_t = match a,m with | Spec.Blake2S,M128 -> 1ul | Spec.Blake2S,M256 -> 1ul | Spec.Blake2B,M256 -> 1ul | _ -> 4ul noextract inline_for_extraction unfold let row_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (row_len a m) noextract inline_for_extraction val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) noextract val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m -> Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==> row_v h0 r1 == row_v h1 r2)) [SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)] noextract inline_for_extraction let salt_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noextract inline_for_extraction let personal_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noeq type blake2s_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint16; node_depth: uint8; inner_length: uint8; salt: lbuffer uint8 8ul; personal: lbuffer uint8 8ul; } inline_for_extraction noextract let get_blake2s_salt (p: blake2s_params) = p.salt inline_for_extraction noextract let get_blake2s_personal (p: blake2s_params) = p.personal inline_for_extraction noextract let set_blake2s_digest_length (p: blake2s_params) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S}) : blake2s_params = {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S}) : blake2s_params = {p with key_length = to_u8 kk} let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop = live h p.salt /\ live h p.personal let blake2s_params_loc (p: blake2s_params) = loc p.salt `union` loc p.personal let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params = Spec.Mkblake2s_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noeq type blake2b_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint32; node_depth: uint8; inner_length: uint8; // Blake2b also contains 14 reserved bytes here, but they seem // unused and to only contain zeros, hence we do not expose them salt: lbuffer uint8 16ul; personal: lbuffer uint8 16ul; } let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop = live h p.salt /\ live h p.personal let blake2b_params_loc (p: blake2b_params) = loc p.salt `union` loc p.personal let blake2b_params_v (h: mem) (p: blake2b_params): GTot Spec.blake2b_params = Spec.Mkblake2b_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noextract inline_for_extraction let blake2_params (a:Spec.alg) = match a with | Spec.Blake2S -> blake2s_params | Spec.Blake2B -> blake2b_params inline_for_extraction noextract let set_digest_length (#a: Spec.alg) (p: blake2_params a) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_digest_length p nn | Spec.Blake2B -> {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_key_length (#a: Spec.alg) (p: blake2_params a) (kk: size_t{v kk <= Spec.max_key a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_key_length p kk | Spec.Blake2B -> {p with key_length = to_u8 kk} inline_for_extraction noextract let get_salt (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (salt_len a) = match a with | Spec.Blake2S -> get_blake2s_salt p | Spec.Blake2B -> p.salt inline_for_extraction noextract let get_personal (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (personal_len a) = match a with | Spec.Blake2S -> get_blake2s_personal p | Spec.Blake2B -> p.personal noextract inline_for_extraction let blake2_params_inv (#a:Spec.alg) (h: mem) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_inv h p | Spec.Blake2B -> blake2b_params_inv h p noextract inline_for_extraction let blake2_params_loc (#a:Spec.alg) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_loc p | Spec.Blake2B -> blake2b_params_loc p
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.Blake2.Core.blake2_params a -> Prims.GTot (Spec.Blake2.Definitions.blake2_params a)
Prims.GTot
[ "sometrivial" ]
[]
[ "Spec.Blake2.Definitions.alg", "FStar.Monotonic.HyperStack.mem", "Hacl.Impl.Blake2.Core.blake2_params", "Hacl.Impl.Blake2.Core.blake2s_params_v", "Hacl.Impl.Blake2.Core.blake2b_params_v", "Spec.Blake2.Definitions.blake2_params" ]
[]
false
false
false
false
false
let blake2_params_v (#a: Spec.alg) (h: mem) (p: blake2_params a) : GTot (Spec.blake2_params a) =
match a with | Spec.Blake2S -> blake2s_params_v h p | Spec.Blake2B -> blake2b_params_v h p
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.get_personal
val get_personal (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (personal_len a)
val get_personal (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (personal_len a)
let get_personal (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (personal_len a) = match a with | Spec.Blake2S -> get_blake2s_personal p | Spec.Blake2B -> p.personal
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 194, "start_col": 0, "start_line": 191 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a noextract inline_for_extraction let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a) noextract inline_for_extraction val zero_element: a:Spec.alg -> m:m_spec -> element_t a m noextract inline_for_extraction let row_len (a:Spec.alg) (m:m_spec) : size_t = match a,m with | Spec.Blake2S,M128 -> 1ul | Spec.Blake2S,M256 -> 1ul | Spec.Blake2B,M256 -> 1ul | _ -> 4ul noextract inline_for_extraction unfold let row_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (row_len a m) noextract inline_for_extraction val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) noextract val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m -> Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==> row_v h0 r1 == row_v h1 r2)) [SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)] noextract inline_for_extraction let salt_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noextract inline_for_extraction let personal_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noeq type blake2s_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint16; node_depth: uint8; inner_length: uint8; salt: lbuffer uint8 8ul; personal: lbuffer uint8 8ul; } inline_for_extraction noextract let get_blake2s_salt (p: blake2s_params) = p.salt inline_for_extraction noextract let get_blake2s_personal (p: blake2s_params) = p.personal inline_for_extraction noextract let set_blake2s_digest_length (p: blake2s_params) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S}) : blake2s_params = {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S}) : blake2s_params = {p with key_length = to_u8 kk} let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop = live h p.salt /\ live h p.personal let blake2s_params_loc (p: blake2s_params) = loc p.salt `union` loc p.personal let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params = Spec.Mkblake2s_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noeq type blake2b_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint32; node_depth: uint8; inner_length: uint8; // Blake2b also contains 14 reserved bytes here, but they seem // unused and to only contain zeros, hence we do not expose them salt: lbuffer uint8 16ul; personal: lbuffer uint8 16ul; } let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop = live h p.salt /\ live h p.personal let blake2b_params_loc (p: blake2b_params) = loc p.salt `union` loc p.personal let blake2b_params_v (h: mem) (p: blake2b_params): GTot Spec.blake2b_params = Spec.Mkblake2b_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noextract inline_for_extraction let blake2_params (a:Spec.alg) = match a with | Spec.Blake2S -> blake2s_params | Spec.Blake2B -> blake2b_params inline_for_extraction noextract let set_digest_length (#a: Spec.alg) (p: blake2_params a) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_digest_length p nn | Spec.Blake2B -> {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_key_length (#a: Spec.alg) (p: blake2_params a) (kk: size_t{v kk <= Spec.max_key a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_key_length p kk | Spec.Blake2B -> {p with key_length = to_u8 kk} inline_for_extraction noextract let get_salt (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (salt_len a) = match a with | Spec.Blake2S -> get_blake2s_salt p | Spec.Blake2B -> p.salt
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Hacl.Impl.Blake2.Core.blake2_params a -> Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.Impl.Blake2.Core.personal_len a)
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "Hacl.Impl.Blake2.Core.blake2_params", "Hacl.Impl.Blake2.Core.get_blake2s_personal", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__personal", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Impl.Blake2.Core.personal_len" ]
[]
false
false
false
false
false
let get_personal (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (personal_len a) =
match a with | Spec.Blake2S -> get_blake2s_personal p | Spec.Blake2B -> p.personal
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.salt_len
val salt_len (a: Spec.alg) : size_t
val salt_len (a: Spec.alg) : size_t
let salt_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 60, "start_col": 0, "start_line": 57 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a noextract inline_for_extraction let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a) noextract inline_for_extraction val zero_element: a:Spec.alg -> m:m_spec -> element_t a m noextract inline_for_extraction let row_len (a:Spec.alg) (m:m_spec) : size_t = match a,m with | Spec.Blake2S,M128 -> 1ul | Spec.Blake2S,M256 -> 1ul | Spec.Blake2B,M256 -> 1ul | _ -> 4ul noextract inline_for_extraction unfold let row_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (row_len a m) noextract inline_for_extraction val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) noextract val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m -> Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==> row_v h0 r1 == row_v h1 r2)) [SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)]
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Blake2.Definitions.alg -> Lib.IntTypes.size_t
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t" ]
[]
false
false
false
true
false
let salt_len (a: Spec.alg) : size_t =
match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.blake2_params
val blake2_params : a: Spec.Blake2.Definitions.alg -> Type0
let blake2_params (a:Spec.alg) = match a with | Spec.Blake2S -> blake2s_params | Spec.Blake2B -> blake2b_params
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 164, "start_col": 0, "start_line": 161 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a noextract inline_for_extraction let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a) noextract inline_for_extraction val zero_element: a:Spec.alg -> m:m_spec -> element_t a m noextract inline_for_extraction let row_len (a:Spec.alg) (m:m_spec) : size_t = match a,m with | Spec.Blake2S,M128 -> 1ul | Spec.Blake2S,M256 -> 1ul | Spec.Blake2B,M256 -> 1ul | _ -> 4ul noextract inline_for_extraction unfold let row_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (row_len a m) noextract inline_for_extraction val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) noextract val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m -> Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==> row_v h0 r1 == row_v h1 r2)) [SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)] noextract inline_for_extraction let salt_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noextract inline_for_extraction let personal_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noeq type blake2s_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint16; node_depth: uint8; inner_length: uint8; salt: lbuffer uint8 8ul; personal: lbuffer uint8 8ul; } inline_for_extraction noextract let get_blake2s_salt (p: blake2s_params) = p.salt inline_for_extraction noextract let get_blake2s_personal (p: blake2s_params) = p.personal inline_for_extraction noextract let set_blake2s_digest_length (p: blake2s_params) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S}) : blake2s_params = {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S}) : blake2s_params = {p with key_length = to_u8 kk} let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop = live h p.salt /\ live h p.personal let blake2s_params_loc (p: blake2s_params) = loc p.salt `union` loc p.personal let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params = Spec.Mkblake2s_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noeq type blake2b_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint32; node_depth: uint8; inner_length: uint8; // Blake2b also contains 14 reserved bytes here, but they seem // unused and to only contain zeros, hence we do not expose them salt: lbuffer uint8 16ul; personal: lbuffer uint8 16ul; } let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop = live h p.salt /\ live h p.personal let blake2b_params_loc (p: blake2b_params) = loc p.salt `union` loc p.personal let blake2b_params_v (h: mem) (p: blake2b_params): GTot Spec.blake2b_params = Spec.Mkblake2b_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal)
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Blake2.Definitions.alg -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "Hacl.Impl.Blake2.Core.blake2s_params", "Hacl.Impl.Blake2.Core.blake2b_params" ]
[]
false
false
false
true
true
let blake2_params (a: Spec.alg) =
match a with | Spec.Blake2S -> blake2s_params | Spec.Blake2B -> blake2b_params
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.element_t
val element_t : a: Spec.Blake2.Definitions.alg -> m: Hacl.Impl.Blake2.Core.m_spec -> Type0
let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a)
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 30, "start_col": 0, "start_line": 25 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Blake2.Definitions.alg -> m: Hacl.Impl.Blake2.Core.m_spec -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "Hacl.Impl.Blake2.Core.m_spec", "FStar.Pervasives.Native.Mktuple2", "Lib.IntVector.vec_t", "Lib.IntTypes.U32", "Lib.IntTypes.U64", "FStar.Pervasives.Native.tuple2", "Hacl.Impl.Blake2.Core.word_t" ]
[]
false
false
false
true
true
let element_t (a: Spec.alg) (m: m_spec) =
match a, m with | Spec.Blake2S, M128 -> (vec_t U32 4) | Spec.Blake2S, M256 -> (vec_t U32 4) | Spec.Blake2B, M256 -> (vec_t U64 4) | _ -> (word_t a)
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.set_digest_length
val set_digest_length (#a: Spec.alg) (p: blake2_params a) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a}) : blake2_params a
val set_digest_length (#a: Spec.alg) (p: blake2_params a) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a}) : blake2_params a
let set_digest_length (#a: Spec.alg) (p: blake2_params a) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_digest_length p nn | Spec.Blake2B -> {p with digest_length = to_u8 nn}
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 53, "end_line": 173, "start_col": 0, "start_line": 167 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a noextract inline_for_extraction let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a) noextract inline_for_extraction val zero_element: a:Spec.alg -> m:m_spec -> element_t a m noextract inline_for_extraction let row_len (a:Spec.alg) (m:m_spec) : size_t = match a,m with | Spec.Blake2S,M128 -> 1ul | Spec.Blake2S,M256 -> 1ul | Spec.Blake2B,M256 -> 1ul | _ -> 4ul noextract inline_for_extraction unfold let row_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (row_len a m) noextract inline_for_extraction val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) noextract val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m -> Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==> row_v h0 r1 == row_v h1 r2)) [SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)] noextract inline_for_extraction let salt_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noextract inline_for_extraction let personal_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noeq type blake2s_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint16; node_depth: uint8; inner_length: uint8; salt: lbuffer uint8 8ul; personal: lbuffer uint8 8ul; } inline_for_extraction noextract let get_blake2s_salt (p: blake2s_params) = p.salt inline_for_extraction noextract let get_blake2s_personal (p: blake2s_params) = p.personal inline_for_extraction noextract let set_blake2s_digest_length (p: blake2s_params) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S}) : blake2s_params = {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S}) : blake2s_params = {p with key_length = to_u8 kk} let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop = live h p.salt /\ live h p.personal let blake2s_params_loc (p: blake2s_params) = loc p.salt `union` loc p.personal let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params = Spec.Mkblake2s_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noeq type blake2b_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint32; node_depth: uint8; inner_length: uint8; // Blake2b also contains 14 reserved bytes here, but they seem // unused and to only contain zeros, hence we do not expose them salt: lbuffer uint8 16ul; personal: lbuffer uint8 16ul; } let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop = live h p.salt /\ live h p.personal let blake2b_params_loc (p: blake2b_params) = loc p.salt `union` loc p.personal let blake2b_params_v (h: mem) (p: blake2b_params): GTot Spec.blake2b_params = Spec.Mkblake2b_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noextract inline_for_extraction let blake2_params (a:Spec.alg) = match a with | Spec.Blake2S -> blake2s_params | Spec.Blake2B -> blake2b_params
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Hacl.Impl.Blake2.Core.blake2_params a -> nn: Lib.IntTypes.size_t {1 <= Lib.IntTypes.v nn /\ Lib.IntTypes.v nn <= Spec.Blake2.Definitions.max_output a} -> Hacl.Impl.Blake2.Core.blake2_params a
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "Hacl.Impl.Blake2.Core.blake2_params", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Spec.Blake2.Definitions.max_output", "Hacl.Impl.Blake2.Core.set_blake2s_digest_length", "Hacl.Impl.Blake2.Core.Mkblake2b_params", "Lib.IntTypes.to_u8", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__key_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", "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__node_depth", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__inner_length", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__salt", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__personal" ]
[]
false
false
false
false
false
let set_digest_length (#a: Spec.alg) (p: blake2_params a) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a}) : blake2_params a =
match a with | Spec.Blake2S -> set_blake2s_digest_length p nn | Spec.Blake2B -> { p with digest_length = to_u8 nn }
false
CQueue.fst
CQueue.elim_vrewrite_no_norm
val elim_vrewrite_no_norm (#opened: inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened (vrewrite v f) (fun _ -> v) (fun _ -> True) (fun h _ h' -> h (vrewrite v f) == f (h' v))
val elim_vrewrite_no_norm (#opened: inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened (vrewrite v f) (fun _ -> v) (fun _ -> True) (fun h _ h' -> h (vrewrite v f) == f (h' v))
let elim_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened (vrewrite v f) (fun _ -> v) (fun _ -> True) (fun h _ h' -> h (vrewrite v f) == f (h' v)) = elim_vrewrite v f
{ "file_name": "share/steel/examples/steel/CQueue.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 19, "end_line": 30, "start_col": 0, "start_line": 22 }
module CQueue open CQueue.LList #set-options "--ide_id_info_off" //Re-define squash, since this module explicitly //replies on proving equalities of the form `t_of v == squash p` //which are delicate in the presence of optimizations that //unfold `Prims.squash (p /\ q)`to _:unit{p /\ q} //See Issue #2496 let squash (p:Type u#a) : Type0 = squash p (* BEGIN library *) let intro_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: (t_of v) -> GTot t) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v)) = intro_vrewrite v f
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "CQueue.LList.fsti.checked" ], "interface_file": true, "source_file": "CQueue.fst" }
[ { "abbrev": false, "full_module": "CQueue.LList", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
v: Steel.Effect.Common.vprop -> f: (_: Steel.Effect.Common.t_of v -> Prims.GTot t) -> Steel.Effect.Atomic.SteelGhost Prims.unit
Steel.Effect.Atomic.SteelGhost
[]
[]
[ "Steel.Memory.inames", "Steel.Effect.Common.vprop", "Steel.Effect.Common.t_of", "Steel.Effect.Atomic.elim_vrewrite", "Prims.unit", "Steel.Effect.Common.vrewrite", "Steel.Effect.Common.rmem", "Prims.l_True", "Prims.eq2" ]
[]
false
true
false
false
false
let elim_vrewrite_no_norm (#opened: inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened (vrewrite v f) (fun _ -> v) (fun _ -> True) (fun h _ h' -> h (vrewrite v f) == f (h' v)) =
elim_vrewrite v f
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.blake2_params_loc
val blake2_params_loc : p: Hacl.Impl.Blake2.Core.blake2_params a -> Prims.GTot LowStar.Monotonic.Buffer.loc
let blake2_params_loc (#a:Spec.alg) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_loc p | Spec.Blake2B -> blake2b_params_loc p
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 40, "end_line": 206, "start_col": 0, "start_line": 203 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a noextract inline_for_extraction let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a) noextract inline_for_extraction val zero_element: a:Spec.alg -> m:m_spec -> element_t a m noextract inline_for_extraction let row_len (a:Spec.alg) (m:m_spec) : size_t = match a,m with | Spec.Blake2S,M128 -> 1ul | Spec.Blake2S,M256 -> 1ul | Spec.Blake2B,M256 -> 1ul | _ -> 4ul noextract inline_for_extraction unfold let row_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (row_len a m) noextract inline_for_extraction val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) noextract val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m -> Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==> row_v h0 r1 == row_v h1 r2)) [SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)] noextract inline_for_extraction let salt_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noextract inline_for_extraction let personal_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noeq type blake2s_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint16; node_depth: uint8; inner_length: uint8; salt: lbuffer uint8 8ul; personal: lbuffer uint8 8ul; } inline_for_extraction noextract let get_blake2s_salt (p: blake2s_params) = p.salt inline_for_extraction noextract let get_blake2s_personal (p: blake2s_params) = p.personal inline_for_extraction noextract let set_blake2s_digest_length (p: blake2s_params) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S}) : blake2s_params = {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S}) : blake2s_params = {p with key_length = to_u8 kk} let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop = live h p.salt /\ live h p.personal let blake2s_params_loc (p: blake2s_params) = loc p.salt `union` loc p.personal let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params = Spec.Mkblake2s_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noeq type blake2b_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint32; node_depth: uint8; inner_length: uint8; // Blake2b also contains 14 reserved bytes here, but they seem // unused and to only contain zeros, hence we do not expose them salt: lbuffer uint8 16ul; personal: lbuffer uint8 16ul; } let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop = live h p.salt /\ live h p.personal let blake2b_params_loc (p: blake2b_params) = loc p.salt `union` loc p.personal let blake2b_params_v (h: mem) (p: blake2b_params): GTot Spec.blake2b_params = Spec.Mkblake2b_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noextract inline_for_extraction let blake2_params (a:Spec.alg) = match a with | Spec.Blake2S -> blake2s_params | Spec.Blake2B -> blake2b_params inline_for_extraction noextract let set_digest_length (#a: Spec.alg) (p: blake2_params a) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_digest_length p nn | Spec.Blake2B -> {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_key_length (#a: Spec.alg) (p: blake2_params a) (kk: size_t{v kk <= Spec.max_key a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_key_length p kk | Spec.Blake2B -> {p with key_length = to_u8 kk} inline_for_extraction noextract let get_salt (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (salt_len a) = match a with | Spec.Blake2S -> get_blake2s_salt p | Spec.Blake2B -> p.salt inline_for_extraction noextract let get_personal (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (personal_len a) = match a with | Spec.Blake2S -> get_blake2s_personal p | Spec.Blake2B -> p.personal noextract inline_for_extraction let blake2_params_inv (#a:Spec.alg) (h: mem) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_inv h p | Spec.Blake2B -> blake2b_params_inv h p
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Hacl.Impl.Blake2.Core.blake2_params a -> Prims.GTot LowStar.Monotonic.Buffer.loc
Prims.GTot
[ "sometrivial" ]
[]
[ "Spec.Blake2.Definitions.alg", "Hacl.Impl.Blake2.Core.blake2_params", "Hacl.Impl.Blake2.Core.blake2s_params_loc", "Hacl.Impl.Blake2.Core.blake2b_params_loc", "LowStar.Monotonic.Buffer.loc" ]
[]
false
false
false
false
false
let blake2_params_loc (#a: Spec.alg) (p: blake2_params a) =
match a with | Spec.Blake2S -> blake2s_params_loc p | Spec.Blake2B -> blake2b_params_loc p
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.permute_via_swaps
val permute_via_swaps : p: FStar.Tactics.CanonCommMonoidSimple.permute -> Type
let permute_via_swaps (p:permute) = (#a:Type) -> (am:amap a) -> xs:list atom -> Lemma (exists ss. p xs == apply_swaps xs ss)
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 48, "end_line": 157, "start_col": 0, "start_line": 155 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s let rec apply_swaps_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (ss:list (swap (length xs))): Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) = match ss with | [] -> () | s::ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: FStar.Tactics.CanonCommMonoidSimple.permute -> Type
Prims.Tot
[ "total" ]
[]
[ "FStar.Tactics.CanonCommMonoidSimple.permute", "FStar.Tactics.CanonCommMonoidSimple.amap", "Prims.list", "FStar.Tactics.CanonCommMonoidSimple.atom", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_Exists", "FStar.Tactics.CanonCommSwaps.swap", "FStar.List.Tot.Base.length", "Prims.eq2", "FStar.Tactics.CanonCommSwaps.apply_swaps", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
false
true
true
let permute_via_swaps (p: permute) =
#a: Type -> am: amap a -> xs: list atom -> Lemma (exists ss. p xs == apply_swaps xs ss)
false
CQueue.fst
CQueue.elim_vpure
val elim_vpure (#opened: _) (p: prop) : SteelGhost unit opened (vpure p) (fun _ -> emp) (fun _ -> True) (fun _ _ _ -> p)
val elim_vpure (#opened: _) (p: prop) : SteelGhost unit opened (vpure p) (fun _ -> emp) (fun _ -> True) (fun _ _ _ -> p)
let elim_vpure (#opened: _) (p: prop) : SteelGhost unit opened (vpure p) (fun _ -> emp) (fun _ -> True) (fun _ _ _ -> p) = change_slprop_rel (vpure p) emp (fun _ _ -> p) (fun m -> pure_interp p m; reveal_emp (); intro_emp m)
{ "file_name": "share/steel/examples/steel/CQueue.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 58, "end_line": 135, "start_col": 0, "start_line": 122 }
module CQueue open CQueue.LList #set-options "--ide_id_info_off" //Re-define squash, since this module explicitly //replies on proving equalities of the form `t_of v == squash p` //which are delicate in the presence of optimizations that //unfold `Prims.squash (p /\ q)`to _:unit{p /\ q} //See Issue #2496 let squash (p:Type u#a) : Type0 = squash p (* BEGIN library *) let intro_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: (t_of v) -> GTot t) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v)) = intro_vrewrite v f let elim_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened (vrewrite v f) (fun _ -> v) (fun _ -> True) (fun h _ h' -> h (vrewrite v f) == f (h' v)) = elim_vrewrite v f let vconst_sel (#a: Type) (x: a) : Tot (selector a (hp_of emp)) = fun _ -> x [@@ __steel_reduce__] let vconst' (#a: Type) (x: a) : GTot vprop' = { hp = hp_of emp; t = a; sel = vconst_sel x; } [@@ __steel_reduce__] let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x) let intro_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened emp (fun _ -> vconst x) (fun _ -> True) (fun _ _ h' -> h' (vconst x) == x) = change_slprop_rel emp (vconst x) (fun _ y -> y == x) (fun _ -> ()) let elim_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened (vconst x) (fun _ -> emp) (fun _ -> True) (fun h _ _ -> h (vconst x) == x) = change_slprop_rel (vconst x) emp (fun y _ -> y == x) (fun _ -> ()) let vpure_sel' (p: prop) : Tot (selector' (squash p) (Steel.Memory.pure p)) = fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m let vpure_sel (p: prop) : Tot (selector (squash p) (Steel.Memory.pure p)) = vpure_sel' p [@@ __steel_reduce__] let vpure' (p: prop) : GTot vprop' = { hp = Steel.Memory.pure p; t = squash p; sel = vpure_sel p; } [@@ __steel_reduce__] let vpure (p: prop) : Tot vprop = VUnit (vpure' p) let intro_vpure (#opened: _) (p: prop) : SteelGhost unit opened emp (fun _ -> vpure p) (fun _ -> p) (fun _ _ h' -> p) = change_slprop_rel emp (vpure p) (fun _ _ -> p) (fun m -> pure_interp p m)
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "CQueue.LList.fsti.checked" ], "interface_file": true, "source_file": "CQueue.fst" }
[ { "abbrev": false, "full_module": "CQueue.LList", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Prims.prop -> Steel.Effect.Atomic.SteelGhost Prims.unit
Steel.Effect.Atomic.SteelGhost
[]
[]
[ "Steel.Memory.inames", "Prims.prop", "Steel.Effect.Atomic.change_slprop_rel", "CQueue.vpure", "Steel.Effect.Common.emp", "Steel.Effect.Common.normal", "Steel.Effect.Common.t_of", "Steel.Memory.mem", "Steel.Memory.intro_emp", "Prims.unit", "Steel.Effect.Common.reveal_emp", "Steel.Memory.pure_interp", "Steel.Effect.Common.vprop", "Steel.Effect.Common.rmem", "Prims.l_True" ]
[]
false
true
false
false
false
let elim_vpure (#opened: _) (p: prop) : SteelGhost unit opened (vpure p) (fun _ -> emp) (fun _ -> True) (fun _ _ _ -> p) =
change_slprop_rel (vpure p) emp (fun _ _ -> p) (fun m -> pure_interp p m; reveal_emp (); intro_emp m)
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.get_salt
val get_salt (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (salt_len a)
val get_salt (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (salt_len a)
let get_salt (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (salt_len a) = match a with | Spec.Blake2S -> get_blake2s_salt p | Spec.Blake2B -> p.salt
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 26, "end_line": 188, "start_col": 0, "start_line": 185 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a noextract inline_for_extraction let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a) noextract inline_for_extraction val zero_element: a:Spec.alg -> m:m_spec -> element_t a m noextract inline_for_extraction let row_len (a:Spec.alg) (m:m_spec) : size_t = match a,m with | Spec.Blake2S,M128 -> 1ul | Spec.Blake2S,M256 -> 1ul | Spec.Blake2B,M256 -> 1ul | _ -> 4ul noextract inline_for_extraction unfold let row_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (row_len a m) noextract inline_for_extraction val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) noextract val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m -> Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==> row_v h0 r1 == row_v h1 r2)) [SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)] noextract inline_for_extraction let salt_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noextract inline_for_extraction let personal_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noeq type blake2s_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint16; node_depth: uint8; inner_length: uint8; salt: lbuffer uint8 8ul; personal: lbuffer uint8 8ul; } inline_for_extraction noextract let get_blake2s_salt (p: blake2s_params) = p.salt inline_for_extraction noextract let get_blake2s_personal (p: blake2s_params) = p.personal inline_for_extraction noextract let set_blake2s_digest_length (p: blake2s_params) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S}) : blake2s_params = {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S}) : blake2s_params = {p with key_length = to_u8 kk} let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop = live h p.salt /\ live h p.personal let blake2s_params_loc (p: blake2s_params) = loc p.salt `union` loc p.personal let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params = Spec.Mkblake2s_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noeq type blake2b_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint32; node_depth: uint8; inner_length: uint8; // Blake2b also contains 14 reserved bytes here, but they seem // unused and to only contain zeros, hence we do not expose them salt: lbuffer uint8 16ul; personal: lbuffer uint8 16ul; } let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop = live h p.salt /\ live h p.personal let blake2b_params_loc (p: blake2b_params) = loc p.salt `union` loc p.personal let blake2b_params_v (h: mem) (p: blake2b_params): GTot Spec.blake2b_params = Spec.Mkblake2b_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noextract inline_for_extraction let blake2_params (a:Spec.alg) = match a with | Spec.Blake2S -> blake2s_params | Spec.Blake2B -> blake2b_params inline_for_extraction noextract let set_digest_length (#a: Spec.alg) (p: blake2_params a) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_digest_length p nn | Spec.Blake2B -> {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_key_length (#a: Spec.alg) (p: blake2_params a) (kk: size_t{v kk <= Spec.max_key a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_key_length p kk | Spec.Blake2B -> {p with key_length = to_u8 kk}
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Hacl.Impl.Blake2.Core.blake2_params a -> Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.Impl.Blake2.Core.salt_len a)
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "Hacl.Impl.Blake2.Core.blake2_params", "Hacl.Impl.Blake2.Core.get_blake2s_salt", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__salt", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Impl.Blake2.Core.salt_len" ]
[]
false
false
false
false
false
let get_salt (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (salt_len a) =
match a with | Spec.Blake2S -> get_blake2s_salt p | Spec.Blake2B -> p.salt
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.permute_correct
val permute_correct : p: FStar.Tactics.CanonCommMonoidSimple.permute -> Type
let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs))
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 52, "end_line": 114, "start_col": 0, "start_line": 112 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: FStar.Tactics.CanonCommMonoidSimple.permute -> Type
Prims.Tot
[ "total" ]
[]
[ "FStar.Tactics.CanonCommMonoidSimple.permute", "FStar.Algebra.CommMonoid.cm", "FStar.Tactics.CanonCommMonoidSimple.amap", "Prims.list", "FStar.Tactics.CanonCommMonoidSimple.atom", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Tactics.CanonCommMonoidSimple.xsdenote", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
false
true
true
let permute_correct (p: permute) =
#a: Type -> m: cm a -> am: amap a -> xs: list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs))
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.state_p
val state_p : a: Spec.Blake2.Definitions.alg -> m: Hacl.Impl.Blake2.Core.m_spec -> Type0
let state_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (4ul *. row_len a m)
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 46, "end_line": 231, "start_col": 7, "start_line": 230 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a noextract inline_for_extraction let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a) noextract inline_for_extraction val zero_element: a:Spec.alg -> m:m_spec -> element_t a m noextract inline_for_extraction let row_len (a:Spec.alg) (m:m_spec) : size_t = match a,m with | Spec.Blake2S,M128 -> 1ul | Spec.Blake2S,M256 -> 1ul | Spec.Blake2B,M256 -> 1ul | _ -> 4ul noextract inline_for_extraction unfold let row_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (row_len a m) noextract inline_for_extraction val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) noextract val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m -> Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==> row_v h0 r1 == row_v h1 r2)) [SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)] noextract inline_for_extraction let salt_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noextract inline_for_extraction let personal_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noeq type blake2s_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint16; node_depth: uint8; inner_length: uint8; salt: lbuffer uint8 8ul; personal: lbuffer uint8 8ul; } inline_for_extraction noextract let get_blake2s_salt (p: blake2s_params) = p.salt inline_for_extraction noextract let get_blake2s_personal (p: blake2s_params) = p.personal inline_for_extraction noextract let set_blake2s_digest_length (p: blake2s_params) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S}) : blake2s_params = {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S}) : blake2s_params = {p with key_length = to_u8 kk} let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop = live h p.salt /\ live h p.personal let blake2s_params_loc (p: blake2s_params) = loc p.salt `union` loc p.personal let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params = Spec.Mkblake2s_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noeq type blake2b_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint32; node_depth: uint8; inner_length: uint8; // Blake2b also contains 14 reserved bytes here, but they seem // unused and to only contain zeros, hence we do not expose them salt: lbuffer uint8 16ul; personal: lbuffer uint8 16ul; } let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop = live h p.salt /\ live h p.personal let blake2b_params_loc (p: blake2b_params) = loc p.salt `union` loc p.personal let blake2b_params_v (h: mem) (p: blake2b_params): GTot Spec.blake2b_params = Spec.Mkblake2b_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noextract inline_for_extraction let blake2_params (a:Spec.alg) = match a with | Spec.Blake2S -> blake2s_params | Spec.Blake2B -> blake2b_params inline_for_extraction noextract let set_digest_length (#a: Spec.alg) (p: blake2_params a) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_digest_length p nn | Spec.Blake2B -> {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_key_length (#a: Spec.alg) (p: blake2_params a) (kk: size_t{v kk <= Spec.max_key a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_key_length p kk | Spec.Blake2B -> {p with key_length = to_u8 kk} inline_for_extraction noextract let get_salt (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (salt_len a) = match a with | Spec.Blake2S -> get_blake2s_salt p | Spec.Blake2B -> p.salt inline_for_extraction noextract let get_personal (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (personal_len a) = match a with | Spec.Blake2S -> get_blake2s_personal p | Spec.Blake2B -> p.personal noextract inline_for_extraction let blake2_params_inv (#a:Spec.alg) (h: mem) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_inv h p | Spec.Blake2B -> blake2b_params_inv h p noextract inline_for_extraction let blake2_params_loc (#a:Spec.alg) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_loc p | Spec.Blake2B -> blake2b_params_loc p noextract inline_for_extraction let blake2_params_v (#a:Spec.alg) (h: mem) (p: blake2_params a) : GTot (Spec.blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_v h p | Spec.Blake2B -> blake2b_params_v h p noextract inline_for_extraction val create_default_params: a:Spec.alg -> salt: lbuffer uint8 (salt_len a) -> personal: lbuffer uint8 (personal_len a) -> Stack (blake2_params a) (requires fun h -> live h salt /\ live h personal /\ as_seq h salt == Seq.create (Spec.salt_length a) (u8 0) /\ as_seq h personal == Seq.create (Spec.personal_length a) (u8 0) ) (ensures (fun h0 p h1 -> h0 == h1 /\ blake2_params_loc p == loc salt `union` loc personal /\ blake2_params_inv h1 p /\ blake2_params_v h1 p == Spec.blake2_default_params a))
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Blake2.Definitions.alg -> m: Hacl.Impl.Blake2.Core.m_spec -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "Hacl.Impl.Blake2.Core.m_spec", "Lib.Buffer.lbuffer", "Hacl.Impl.Blake2.Core.element_t", "Lib.IntTypes.op_Star_Dot", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Blake2.Core.row_len" ]
[]
false
false
false
true
true
let state_p (a: Spec.alg) (m: m_spec) =
lbuffer (element_t a m) (4ul *. row_len a m)
false
CQueue.fst
CQueue.intro_vrewrite_no_norm
val intro_vrewrite_no_norm (#opened: inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
val intro_vrewrite_no_norm (#opened: inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
let intro_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: (t_of v) -> GTot t) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v)) = intro_vrewrite v f
{ "file_name": "share/steel/examples/steel/CQueue.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 20, "end_line": 20, "start_col": 0, "start_line": 15 }
module CQueue open CQueue.LList #set-options "--ide_id_info_off" //Re-define squash, since this module explicitly //replies on proving equalities of the form `t_of v == squash p` //which are delicate in the presence of optimizations that //unfold `Prims.squash (p /\ q)`to _:unit{p /\ q} //See Issue #2496 let squash (p:Type u#a) : Type0 = squash p (* BEGIN library *)
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "CQueue.LList.fsti.checked" ], "interface_file": true, "source_file": "CQueue.fst" }
[ { "abbrev": false, "full_module": "CQueue.LList", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
v: Steel.Effect.Common.vprop -> f: (_: Steel.Effect.Common.t_of v -> Prims.GTot t) -> Steel.Effect.Atomic.SteelGhost Prims.unit
Steel.Effect.Atomic.SteelGhost
[]
[]
[ "Steel.Memory.inames", "Steel.Effect.Common.vprop", "Steel.Effect.Common.t_of", "Steel.Effect.Atomic.intro_vrewrite", "Prims.unit", "Steel.Effect.Common.vrewrite", "Steel.Effect.Common.rmem", "Prims.l_True", "Prims.eq2" ]
[]
false
true
false
false
false
let intro_vrewrite_no_norm (#opened: inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v)) =
intro_vrewrite v f
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.set_key_length
val set_key_length (#a: Spec.alg) (p: blake2_params a) (kk: size_t{v kk <= Spec.max_key a}) : blake2_params a
val set_key_length (#a: Spec.alg) (p: blake2_params a) (kk: size_t{v kk <= Spec.max_key a}) : blake2_params a
let set_key_length (#a: Spec.alg) (p: blake2_params a) (kk: size_t{v kk <= Spec.max_key a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_key_length p kk | Spec.Blake2B -> {p with key_length = to_u8 kk}
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 182, "start_col": 0, "start_line": 176 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a noextract inline_for_extraction let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a) noextract inline_for_extraction val zero_element: a:Spec.alg -> m:m_spec -> element_t a m noextract inline_for_extraction let row_len (a:Spec.alg) (m:m_spec) : size_t = match a,m with | Spec.Blake2S,M128 -> 1ul | Spec.Blake2S,M256 -> 1ul | Spec.Blake2B,M256 -> 1ul | _ -> 4ul noextract inline_for_extraction unfold let row_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (row_len a m) noextract inline_for_extraction val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) noextract val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m -> Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==> row_v h0 r1 == row_v h1 r2)) [SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)] noextract inline_for_extraction let salt_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noextract inline_for_extraction let personal_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noeq type blake2s_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint16; node_depth: uint8; inner_length: uint8; salt: lbuffer uint8 8ul; personal: lbuffer uint8 8ul; } inline_for_extraction noextract let get_blake2s_salt (p: blake2s_params) = p.salt inline_for_extraction noextract let get_blake2s_personal (p: blake2s_params) = p.personal inline_for_extraction noextract let set_blake2s_digest_length (p: blake2s_params) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S}) : blake2s_params = {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S}) : blake2s_params = {p with key_length = to_u8 kk} let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop = live h p.salt /\ live h p.personal let blake2s_params_loc (p: blake2s_params) = loc p.salt `union` loc p.personal let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params = Spec.Mkblake2s_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noeq type blake2b_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint32; node_depth: uint8; inner_length: uint8; // Blake2b also contains 14 reserved bytes here, but they seem // unused and to only contain zeros, hence we do not expose them salt: lbuffer uint8 16ul; personal: lbuffer uint8 16ul; } let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop = live h p.salt /\ live h p.personal let blake2b_params_loc (p: blake2b_params) = loc p.salt `union` loc p.personal let blake2b_params_v (h: mem) (p: blake2b_params): GTot Spec.blake2b_params = Spec.Mkblake2b_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noextract inline_for_extraction let blake2_params (a:Spec.alg) = match a with | Spec.Blake2S -> blake2s_params | Spec.Blake2B -> blake2b_params inline_for_extraction noextract let set_digest_length (#a: Spec.alg) (p: blake2_params a) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_digest_length p nn | Spec.Blake2B -> {p with digest_length = to_u8 nn}
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Hacl.Impl.Blake2.Core.blake2_params a -> kk: Lib.IntTypes.size_t{Lib.IntTypes.v kk <= Spec.Blake2.Definitions.max_key a} -> Hacl.Impl.Blake2.Core.blake2_params a
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "Hacl.Impl.Blake2.Core.blake2_params", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Spec.Blake2.Definitions.max_key", "Hacl.Impl.Blake2.Core.set_blake2s_key_length", "Hacl.Impl.Blake2.Core.Mkblake2b_params", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__digest_length", "Lib.IntTypes.to_u8", "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", "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__node_depth", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__inner_length", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__salt", "Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__personal" ]
[]
false
false
false
false
false
let set_key_length (#a: Spec.alg) (p: blake2_params a) (kk: size_t{v kk <= Spec.max_key a}) : blake2_params a =
match a with | Spec.Blake2S -> set_blake2s_key_length p kk | Spec.Blake2B -> { p with key_length = to_u8 kk }
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.atom
val atom:eqtype
val atom:eqtype
let atom : eqtype = nat
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 23, "end_line": 40, "start_col": 0, "start_line": 40 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "Prims.nat" ]
[]
false
false
false
true
false
let atom:eqtype =
nat
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.sort
val sort:permute
val sort:permute
let sort : permute = List.Tot.Base.sortWith #nat (compare_of_bool (<))
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 70, "end_line": 177, "start_col": 0, "start_line": 177 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s let rec apply_swaps_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (ss:list (swap (length xs))): Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) = match ss with | [] -> () | s::ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss' let permute_via_swaps (p:permute) = (#a:Type) -> (am:amap a) -> xs:list atom -> Lemma (exists ss. p xs == apply_swaps xs ss) let permute_via_swaps_correct_aux (p:permute) (pvs:permute_via_swaps p) (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (p xs)) = pvs am xs; assert(exists ss. p xs == apply_swaps xs ss); exists_elim (xsdenote m am xs == xsdenote m am (p xs)) (() <: squash (exists ss. p xs == apply_swaps xs ss)) (fun ss -> apply_swaps_correct m am xs ss) let permute_via_swaps_correct (p:permute) (pvs:permute_via_swaps p) : permute_correct p = fun #a -> permute_via_swaps_correct_aux p pvs #a (***** Sorting atoms is a correct permutation (since it can be done by swaps) *) // Here we sort the variable numbers
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Tactics.CanonCommMonoidSimple.permute
Prims.Tot
[ "total" ]
[]
[ "FStar.List.Tot.Base.sortWith", "Prims.nat", "FStar.List.Tot.Base.compare_of_bool", "Prims.int", "Prims.op_LessThan" ]
[]
false
false
false
true
false
let sort:permute =
List.Tot.Base.sortWith #nat (compare_of_bool ( < ))
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.size_row
val size_row : al: Spec.Blake2.Definitions.alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
let size_row al = 4ul *. size (Spec.size_word al)
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 49, "end_line": 350, "start_col": 0, "start_line": 350 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a noextract inline_for_extraction let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a) noextract inline_for_extraction val zero_element: a:Spec.alg -> m:m_spec -> element_t a m noextract inline_for_extraction let row_len (a:Spec.alg) (m:m_spec) : size_t = match a,m with | Spec.Blake2S,M128 -> 1ul | Spec.Blake2S,M256 -> 1ul | Spec.Blake2B,M256 -> 1ul | _ -> 4ul noextract inline_for_extraction unfold let row_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (row_len a m) noextract inline_for_extraction val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) noextract val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m -> Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==> row_v h0 r1 == row_v h1 r2)) [SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)] noextract inline_for_extraction let salt_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noextract inline_for_extraction let personal_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noeq type blake2s_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint16; node_depth: uint8; inner_length: uint8; salt: lbuffer uint8 8ul; personal: lbuffer uint8 8ul; } inline_for_extraction noextract let get_blake2s_salt (p: blake2s_params) = p.salt inline_for_extraction noextract let get_blake2s_personal (p: blake2s_params) = p.personal inline_for_extraction noextract let set_blake2s_digest_length (p: blake2s_params) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S}) : blake2s_params = {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S}) : blake2s_params = {p with key_length = to_u8 kk} let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop = live h p.salt /\ live h p.personal let blake2s_params_loc (p: blake2s_params) = loc p.salt `union` loc p.personal let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params = Spec.Mkblake2s_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noeq type blake2b_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint32; node_depth: uint8; inner_length: uint8; // Blake2b also contains 14 reserved bytes here, but they seem // unused and to only contain zeros, hence we do not expose them salt: lbuffer uint8 16ul; personal: lbuffer uint8 16ul; } let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop = live h p.salt /\ live h p.personal let blake2b_params_loc (p: blake2b_params) = loc p.salt `union` loc p.personal let blake2b_params_v (h: mem) (p: blake2b_params): GTot Spec.blake2b_params = Spec.Mkblake2b_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noextract inline_for_extraction let blake2_params (a:Spec.alg) = match a with | Spec.Blake2S -> blake2s_params | Spec.Blake2B -> blake2b_params inline_for_extraction noextract let set_digest_length (#a: Spec.alg) (p: blake2_params a) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_digest_length p nn | Spec.Blake2B -> {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_key_length (#a: Spec.alg) (p: blake2_params a) (kk: size_t{v kk <= Spec.max_key a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_key_length p kk | Spec.Blake2B -> {p with key_length = to_u8 kk} inline_for_extraction noextract let get_salt (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (salt_len a) = match a with | Spec.Blake2S -> get_blake2s_salt p | Spec.Blake2B -> p.salt inline_for_extraction noextract let get_personal (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (personal_len a) = match a with | Spec.Blake2S -> get_blake2s_personal p | Spec.Blake2B -> p.personal noextract inline_for_extraction let blake2_params_inv (#a:Spec.alg) (h: mem) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_inv h p | Spec.Blake2B -> blake2b_params_inv h p noextract inline_for_extraction let blake2_params_loc (#a:Spec.alg) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_loc p | Spec.Blake2B -> blake2b_params_loc p noextract inline_for_extraction let blake2_params_v (#a:Spec.alg) (h: mem) (p: blake2_params a) : GTot (Spec.blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_v h p | Spec.Blake2B -> blake2b_params_v h p noextract inline_for_extraction val create_default_params: a:Spec.alg -> salt: lbuffer uint8 (salt_len a) -> personal: lbuffer uint8 (personal_len a) -> Stack (blake2_params a) (requires fun h -> live h salt /\ live h personal /\ as_seq h salt == Seq.create (Spec.salt_length a) (u8 0) /\ as_seq h personal == Seq.create (Spec.personal_length a) (u8 0) ) (ensures (fun h0 p h1 -> h0 == h1 /\ blake2_params_loc p == loc salt `union` loc personal /\ blake2_params_inv h1 p /\ blake2_params_v h1 p == Spec.blake2_default_params a)) noextract inline_for_extraction unfold let state_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (4ul *. row_len a m) noextract inline_for_extraction unfold let index_t = n:size_t{v n < 4} noextract inline_for_extraction let g_rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) : GTot (row_p a m) = gsub st (idx *. row_len a m) (row_len a m) val g_rowi_disjoint: #a:Spec.alg -> #m:m_spec -> st:state_p a m -> idx1:index_t -> idx2:index_t -> Lemma (ensures (v idx1 <> v idx2 ==> disjoint (g_rowi st idx1) (g_rowi st idx2))) [SMTPat (disjoint (g_rowi st idx1) (g_rowi st idx2))] val g_rowi_unchanged: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t -> Lemma (requires (as_seq h0 st == as_seq h1 st)) (ensures (as_seq h0 (g_rowi st i) == as_seq h1 (g_rowi st i))) [SMTPat (as_seq h0 (g_rowi st i)); SMTPat (as_seq h1 (g_rowi st i))] val g_rowi_disjoint_other: #a:Spec.alg -> #m:m_spec -> #b:Type -> st:state_p a m -> i:index_t -> x:buffer b -> Lemma(requires (disjoint st x)) (ensures (disjoint (g_rowi st i) x)) [SMTPat (disjoint (g_rowi st i) x)] inline_for_extraction noextract val state_v: #a:Spec.alg -> #m:m_spec -> mem -> state_p a m -> GTot (Spec.state a) noextract val state_v_eq_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> st1:state_p a m -> st2:state_p a m -> Lemma (requires (as_seq h0 st1 == as_seq h1 st2)) (ensures (state_v h0 st1 == state_v h1 st2)) [SMTPat (state_v #a #m h0 st1); SMTPat (state_v #a #m h1 st2)] noextract val state_v_rowi_lemma: #a:Spec.alg -> #m:m_spec -> h:mem -> st:state_p a m -> i:index_t -> Lemma (requires (live h st)) (ensures (Lib.Sequence.((state_v h st).[v i] == row_v h (g_rowi st i)))) [SMTPat (row_v h (g_rowi st i))] noextract val state_v_live_rowi_lemma: #a:Spec.alg -> #m:m_spec -> h:mem -> st:state_p a m -> i:index_t -> Lemma (requires (live h st)) (ensures (live h (g_rowi st i))) [SMTPat (live h (g_rowi st i))] noextract val modifies_one_row: a:Spec.alg -> m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t -> j:index_t -> Lemma (requires (live h0 st /\ modifies (loc (g_rowi st i)) h0 h1 /\ v i <> v j)) (ensures (row_v h1 (g_rowi st j) == row_v h0 (g_rowi st j))) [SMTPat (modifies (loc (g_rowi st i)) h0 h1); SMTPat (row_v h1 (g_rowi st j))] noextract val modifies_row_state: a:Spec.alg -> m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t -> Lemma (requires (live h0 st /\ modifies (loc (g_rowi st i)) h0 h1)) (ensures (modifies (loc st) h0 h1 /\ state_v h1 st == Lib.Sequence.((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))) [SMTPat (modifies (loc (g_rowi #a #m st i)) h0 h1)] noextract inline_for_extraction val rowi: #a:Spec.alg -> #m:m_spec -> st:state_p a m -> idx:index_t -> Stack (row_p a m) (requires (fun h -> live h st)) (ensures (fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == g_rowi st idx)) noextract inline_for_extraction val xor_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:row_p a m -> Stack unit (requires (fun h -> live h r1 /\ live h r2 /\ disjoint r1 r2)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( row_v h0 r1 ^| row_v h0 r2 ))) noextract inline_for_extraction val add_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:row_p a m -> Stack unit (requires (fun h -> live h r1 /\ live h r2 /\ disjoint r1 r2)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( row_v h0 r1 +| row_v h0 r2 ))) noextract inline_for_extraction val ror_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:rotval (Spec.wt a) -> Stack unit (requires (fun h -> live h r1)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( row_v h0 r1 >>>| r2 ))) noextract inline_for_extraction val permr_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> n:index_t -> Stack unit (requires (fun h -> live h r1)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( rotr (row_v h0 r1) (v n) ))) val create4_lemma: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a -> Lemma (ensures ( let l = [ x0; x1; x2; x3 ] in assert_norm (List.Tot.length l = 4); Lib.Sequence.createL l == Lib.Sequence.create4 x0 x1 x2 x3)) [SMTPat (Lib.Sequence.createL [x0;x1;x2;x3])] noextract inline_for_extraction val alloc_row: a:Spec.alg -> m:m_spec -> StackInline (row_p a m) (requires (fun h -> True)) (ensures (fun h0 r h1 -> stack_allocated r h0 h1 (Lib.Sequence.create (v (row_len a m)) (zero_element a m)) /\ live h1 r /\ row_v h1 r == Spec.zero_row a)) noextract inline_for_extraction val create_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> w0:word_t a -> w1:word_t a -> w2:word_t a -> w3:word_t a -> Stack unit (requires (fun h -> live h r1)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( create_row w0 w1 w2 w3 ))) noextract inline_for_extraction val load_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> ws:lbuffer (word_t a) 4ul -> Stack unit (requires (fun h -> live h r1 /\ live h ws /\ disjoint r1 ws)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( load_row (as_seq h0 ws))))
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
al: Spec.Blake2.Definitions.alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "Lib.IntTypes.op_Star_Dot", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size", "Spec.Blake2.Definitions.size_word", "Lib.IntTypes.int_t" ]
[]
false
false
false
true
false
let size_row al =
4ul *. size (Spec.size_word al)
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.sort_correct
val sort_correct:permute_correct sort
val sort_correct:permute_correct sort
let sort_correct : permute_correct sort = (fun #a -> sort_correct_aux #a)
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 73, "end_line": 190, "start_col": 0, "start_line": 190 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s let rec apply_swaps_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (ss:list (swap (length xs))): Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) = match ss with | [] -> () | s::ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss' let permute_via_swaps (p:permute) = (#a:Type) -> (am:amap a) -> xs:list atom -> Lemma (exists ss. p xs == apply_swaps xs ss) let permute_via_swaps_correct_aux (p:permute) (pvs:permute_via_swaps p) (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (p xs)) = pvs am xs; assert(exists ss. p xs == apply_swaps xs ss); exists_elim (xsdenote m am xs == xsdenote m am (p xs)) (() <: squash (exists ss. p xs == apply_swaps xs ss)) (fun ss -> apply_swaps_correct m am xs ss) let permute_via_swaps_correct (p:permute) (pvs:permute_via_swaps p) : permute_correct p = fun #a -> permute_via_swaps_correct_aux p pvs #a (***** Sorting atoms is a correct permutation (since it can be done by swaps) *) // Here we sort the variable numbers let sort : permute = List.Tot.Base.sortWith #nat (compare_of_bool (<)) let sort_via_swaps (#a:Type) (am : amap a) (xs:list atom) : Lemma (exists ss. sort xs == apply_swaps xs ss) = List.Tot.Properties.sortWith_permutation #nat (compare_of_bool (<)) xs; let ss = equal_counts_implies_swaps #nat xs (sort xs) in () let sort_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (sort xs)) = permute_via_swaps_correct sort (fun #a am -> sort_via_swaps am) m am xs
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Tactics.CanonCommMonoidSimple.permute_correct FStar.Tactics.CanonCommMonoidSimple.sort
Prims.Tot
[ "total" ]
[]
[ "FStar.Tactics.CanonCommMonoidSimple.sort_correct_aux", "FStar.Algebra.CommMonoid.cm", "FStar.Tactics.CanonCommMonoidSimple.amap", "Prims.list", "FStar.Tactics.CanonCommMonoidSimple.atom", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Tactics.CanonCommMonoidSimple.xsdenote", "FStar.Tactics.CanonCommMonoidSimple.sort", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
false
true
false
let sort_correct:permute_correct sort =
(fun #a -> sort_correct_aux #a)
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.blake2_params_inv
val blake2_params_inv : h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.Blake2.Core.blake2_params a -> Prims.prop
let blake2_params_inv (#a:Spec.alg) (h: mem) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_inv h p | Spec.Blake2B -> blake2b_params_inv h p
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 42, "end_line": 200, "start_col": 0, "start_line": 197 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a noextract inline_for_extraction let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a) noextract inline_for_extraction val zero_element: a:Spec.alg -> m:m_spec -> element_t a m noextract inline_for_extraction let row_len (a:Spec.alg) (m:m_spec) : size_t = match a,m with | Spec.Blake2S,M128 -> 1ul | Spec.Blake2S,M256 -> 1ul | Spec.Blake2B,M256 -> 1ul | _ -> 4ul noextract inline_for_extraction unfold let row_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (row_len a m) noextract inline_for_extraction val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) noextract val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m -> Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==> row_v h0 r1 == row_v h1 r2)) [SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)] noextract inline_for_extraction let salt_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noextract inline_for_extraction let personal_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noeq type blake2s_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint16; node_depth: uint8; inner_length: uint8; salt: lbuffer uint8 8ul; personal: lbuffer uint8 8ul; } inline_for_extraction noextract let get_blake2s_salt (p: blake2s_params) = p.salt inline_for_extraction noextract let get_blake2s_personal (p: blake2s_params) = p.personal inline_for_extraction noextract let set_blake2s_digest_length (p: blake2s_params) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S}) : blake2s_params = {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S}) : blake2s_params = {p with key_length = to_u8 kk} let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop = live h p.salt /\ live h p.personal let blake2s_params_loc (p: blake2s_params) = loc p.salt `union` loc p.personal let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params = Spec.Mkblake2s_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noeq type blake2b_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint32; node_depth: uint8; inner_length: uint8; // Blake2b also contains 14 reserved bytes here, but they seem // unused and to only contain zeros, hence we do not expose them salt: lbuffer uint8 16ul; personal: lbuffer uint8 16ul; } let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop = live h p.salt /\ live h p.personal let blake2b_params_loc (p: blake2b_params) = loc p.salt `union` loc p.personal let blake2b_params_v (h: mem) (p: blake2b_params): GTot Spec.blake2b_params = Spec.Mkblake2b_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noextract inline_for_extraction let blake2_params (a:Spec.alg) = match a with | Spec.Blake2S -> blake2s_params | Spec.Blake2B -> blake2b_params inline_for_extraction noextract let set_digest_length (#a: Spec.alg) (p: blake2_params a) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_digest_length p nn | Spec.Blake2B -> {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_key_length (#a: Spec.alg) (p: blake2_params a) (kk: size_t{v kk <= Spec.max_key a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_key_length p kk | Spec.Blake2B -> {p with key_length = to_u8 kk} inline_for_extraction noextract let get_salt (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (salt_len a) = match a with | Spec.Blake2S -> get_blake2s_salt p | Spec.Blake2B -> p.salt inline_for_extraction noextract let get_personal (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (personal_len a) = match a with | Spec.Blake2S -> get_blake2s_personal p | Spec.Blake2B -> p.personal
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.Blake2.Core.blake2_params a -> Prims.prop
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "FStar.Monotonic.HyperStack.mem", "Hacl.Impl.Blake2.Core.blake2_params", "Hacl.Impl.Blake2.Core.blake2s_params_inv", "Hacl.Impl.Blake2.Core.blake2b_params_inv", "Prims.prop" ]
[]
false
false
false
false
true
let blake2_params_inv (#a: Spec.alg) (h: mem) (p: blake2_params a) =
match a with | Spec.Blake2S -> blake2s_params_inv h p | Spec.Blake2B -> blake2b_params_inv h p
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.canon
val canon : e: FStar.Tactics.CanonCommMonoidSimple.exp -> Prims.list FStar.Tactics.CanonCommMonoidSimple.atom
let canon (e:exp) = sort (flatten e)
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 36, "end_line": 195, "start_col": 0, "start_line": 195 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s let rec apply_swaps_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (ss:list (swap (length xs))): Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) = match ss with | [] -> () | s::ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss' let permute_via_swaps (p:permute) = (#a:Type) -> (am:amap a) -> xs:list atom -> Lemma (exists ss. p xs == apply_swaps xs ss) let permute_via_swaps_correct_aux (p:permute) (pvs:permute_via_swaps p) (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (p xs)) = pvs am xs; assert(exists ss. p xs == apply_swaps xs ss); exists_elim (xsdenote m am xs == xsdenote m am (p xs)) (() <: squash (exists ss. p xs == apply_swaps xs ss)) (fun ss -> apply_swaps_correct m am xs ss) let permute_via_swaps_correct (p:permute) (pvs:permute_via_swaps p) : permute_correct p = fun #a -> permute_via_swaps_correct_aux p pvs #a (***** Sorting atoms is a correct permutation (since it can be done by swaps) *) // Here we sort the variable numbers let sort : permute = List.Tot.Base.sortWith #nat (compare_of_bool (<)) let sort_via_swaps (#a:Type) (am : amap a) (xs:list atom) : Lemma (exists ss. sort xs == apply_swaps xs ss) = List.Tot.Properties.sortWith_permutation #nat (compare_of_bool (<)) xs; let ss = equal_counts_implies_swaps #nat xs (sort xs) in () let sort_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (sort xs)) = permute_via_swaps_correct sort (fun #a am -> sort_via_swaps am) m am xs let sort_correct : permute_correct sort = (fun #a -> sort_correct_aux #a) (***** Canonicalization tactics *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: FStar.Tactics.CanonCommMonoidSimple.exp -> Prims.list FStar.Tactics.CanonCommMonoidSimple.atom
Prims.Tot
[ "total" ]
[]
[ "FStar.Tactics.CanonCommMonoidSimple.exp", "FStar.Tactics.CanonCommMonoidSimple.sort", "FStar.Tactics.CanonCommMonoidSimple.flatten", "Prims.list", "FStar.Tactics.CanonCommMonoidSimple.atom" ]
[]
false
false
false
true
false
let canon (e: exp) =
sort (flatten e)
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.sort_correct_aux
val sort_correct_aux (#a: Type) (m: cm a) (am: amap a) (xs: list atom) : Lemma (xsdenote m am xs == xsdenote m am (sort xs))
val sort_correct_aux (#a: Type) (m: cm a) (am: amap a) (xs: list atom) : Lemma (xsdenote m am xs == xsdenote m am (sort xs))
let sort_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (sort xs)) = permute_via_swaps_correct sort (fun #a am -> sort_via_swaps am) m am xs
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 73, "end_line": 188, "start_col": 0, "start_line": 186 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s let rec apply_swaps_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (ss:list (swap (length xs))): Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) = match ss with | [] -> () | s::ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss' let permute_via_swaps (p:permute) = (#a:Type) -> (am:amap a) -> xs:list atom -> Lemma (exists ss. p xs == apply_swaps xs ss) let permute_via_swaps_correct_aux (p:permute) (pvs:permute_via_swaps p) (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (p xs)) = pvs am xs; assert(exists ss. p xs == apply_swaps xs ss); exists_elim (xsdenote m am xs == xsdenote m am (p xs)) (() <: squash (exists ss. p xs == apply_swaps xs ss)) (fun ss -> apply_swaps_correct m am xs ss) let permute_via_swaps_correct (p:permute) (pvs:permute_via_swaps p) : permute_correct p = fun #a -> permute_via_swaps_correct_aux p pvs #a (***** Sorting atoms is a correct permutation (since it can be done by swaps) *) // Here we sort the variable numbers let sort : permute = List.Tot.Base.sortWith #nat (compare_of_bool (<)) let sort_via_swaps (#a:Type) (am : amap a) (xs:list atom) : Lemma (exists ss. sort xs == apply_swaps xs ss) = List.Tot.Properties.sortWith_permutation #nat (compare_of_bool (<)) xs; let ss = equal_counts_implies_swaps #nat xs (sort xs) in ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.Algebra.CommMonoid.cm a -> am: FStar.Tactics.CanonCommMonoidSimple.amap a -> xs: Prims.list FStar.Tactics.CanonCommMonoidSimple.atom -> FStar.Pervasives.Lemma (ensures FStar.Tactics.CanonCommMonoidSimple.xsdenote m am xs == FStar.Tactics.CanonCommMonoidSimple.xsdenote m am (FStar.Tactics.CanonCommMonoidSimple.sort xs))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Algebra.CommMonoid.cm", "FStar.Tactics.CanonCommMonoidSimple.amap", "Prims.list", "FStar.Tactics.CanonCommMonoidSimple.atom", "FStar.Tactics.CanonCommMonoidSimple.permute_via_swaps_correct", "FStar.Tactics.CanonCommMonoidSimple.sort", "FStar.Tactics.CanonCommMonoidSimple.sort_via_swaps", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_Exists", "FStar.Tactics.CanonCommSwaps.swap", "FStar.List.Tot.Base.length", "Prims.eq2", "FStar.Tactics.CanonCommSwaps.apply_swaps", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Tactics.CanonCommMonoidSimple.xsdenote" ]
[]
false
false
true
false
false
let sort_correct_aux (#a: Type) (m: cm a) (am: amap a) (xs: list atom) : Lemma (xsdenote m am xs == xsdenote m am (sort xs)) =
permute_via_swaps_correct sort (fun #a am -> sort_via_swaps am) m am xs
false
CQueue.fst
CQueue.elim_vconst
val elim_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened (vconst x) (fun _ -> emp) (fun _ -> True) (fun h _ _ -> h (vconst x) == x)
val elim_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened (vconst x) (fun _ -> emp) (fun _ -> True) (fun h _ _ -> h (vconst x) == x)
let elim_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened (vconst x) (fun _ -> emp) (fun _ -> True) (fun h _ _ -> h (vconst x) == x) = change_slprop_rel (vconst x) emp (fun y _ -> y == x) (fun _ -> ())
{ "file_name": "share/steel/examples/steel/CQueue.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 17, "end_line": 82, "start_col": 0, "start_line": 68 }
module CQueue open CQueue.LList #set-options "--ide_id_info_off" //Re-define squash, since this module explicitly //replies on proving equalities of the form `t_of v == squash p` //which are delicate in the presence of optimizations that //unfold `Prims.squash (p /\ q)`to _:unit{p /\ q} //See Issue #2496 let squash (p:Type u#a) : Type0 = squash p (* BEGIN library *) let intro_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: (t_of v) -> GTot t) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v)) = intro_vrewrite v f let elim_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened (vrewrite v f) (fun _ -> v) (fun _ -> True) (fun h _ h' -> h (vrewrite v f) == f (h' v)) = elim_vrewrite v f let vconst_sel (#a: Type) (x: a) : Tot (selector a (hp_of emp)) = fun _ -> x [@@ __steel_reduce__] let vconst' (#a: Type) (x: a) : GTot vprop' = { hp = hp_of emp; t = a; sel = vconst_sel x; } [@@ __steel_reduce__] let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x) let intro_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened emp (fun _ -> vconst x) (fun _ -> True) (fun _ _ h' -> h' (vconst x) == x) = change_slprop_rel emp (vconst x) (fun _ y -> y == x) (fun _ -> ())
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "CQueue.LList.fsti.checked" ], "interface_file": true, "source_file": "CQueue.fst" }
[ { "abbrev": false, "full_module": "CQueue.LList", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> Steel.Effect.Atomic.SteelGhost Prims.unit
Steel.Effect.Atomic.SteelGhost
[]
[]
[ "Steel.Memory.inames", "Steel.Effect.Atomic.change_slprop_rel", "CQueue.vconst", "Steel.Effect.Common.emp", "Steel.Effect.Common.normal", "Steel.Effect.Common.t_of", "Prims.eq2", "Prims.prop", "Steel.Memory.mem", "Prims.unit", "Steel.Effect.Common.vprop", "Steel.Effect.Common.rmem", "Prims.l_True" ]
[]
false
true
false
false
false
let elim_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened (vconst x) (fun _ -> emp) (fun _ -> True) (fun h _ _ -> h (vconst x) == x) =
change_slprop_rel (vconst x) emp (fun y _ -> y == x) (fun _ -> ())
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.exp_to_string
val exp_to_string (e: exp) : string
val exp_to_string (e: exp) : string
let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")"
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 51, "end_line": 52, "start_col": 0, "start_line": 47 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: FStar.Tactics.CanonCommMonoidSimple.exp -> Prims.string
Prims.Tot
[ "total" ]
[]
[ "FStar.Tactics.CanonCommMonoidSimple.exp", "FStar.Tactics.CanonCommMonoidSimple.atom", "Prims.op_Hat", "Prims.string_of_int", "FStar.Tactics.CanonCommMonoidSimple.exp_to_string", "Prims.string" ]
[ "recursion" ]
false
false
false
true
false
let rec exp_to_string (e: exp) : string =
match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")"
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.flatten_correct
val flatten_correct (#a: Type) (m: cm a) (am: amap a) (e: exp) : Lemma (mdenote m am e == xsdenote m am (flatten e))
val flatten_correct (#a: Type) (m: cm a) (am: amap a) (e: exp) : Lemma (mdenote m am e == xsdenote m am (flatten e))
let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 66, "end_line": 104, "start_col": 0, "start_line": 99 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.Algebra.CommMonoid.cm a -> am: FStar.Tactics.CanonCommMonoidSimple.amap a -> e: FStar.Tactics.CanonCommMonoidSimple.exp -> FStar.Pervasives.Lemma (ensures FStar.Tactics.CanonCommMonoidSimple.mdenote m am e == FStar.Tactics.CanonCommMonoidSimple.xsdenote m am (FStar.Tactics.CanonCommMonoidSimple.flatten e))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Algebra.CommMonoid.cm", "FStar.Tactics.CanonCommMonoidSimple.amap", "FStar.Tactics.CanonCommMonoidSimple.exp", "FStar.Tactics.CanonCommMonoidSimple.atom", "FStar.Tactics.CanonCommMonoidSimple.flatten_correct", "Prims.unit", "FStar.Tactics.CanonCommMonoidSimple.flatten_correct_aux", "FStar.Tactics.CanonCommMonoidSimple.flatten", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Tactics.CanonCommMonoidSimple.mdenote", "FStar.Tactics.CanonCommMonoidSimple.xsdenote", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec flatten_correct (#a: Type) (m: cm a) (am: amap a) (e: exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) =
match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.reification
val reification (#a: Type) (m: cm a) (ts: list term) (am: amap a) (t: term) : Tac (exp * list term * amap a)
val reification (#a: Type) (m: cm a) (ts: list term) (am: amap a) (t: term) : Tac (exp * list term * amap a)
let reification (#a:Type) (m:cm a) (ts:list term) (am:amap a) (t:term) : Tac (exp * list term * amap a) = let mult = norm_term [delta;zeta;iota] (quote (CM?.mult m)) in let unit = norm_term [delta;zeta;iota] (quote (CM?.unit m)) in let t = norm_term [delta;zeta;iota] t in reification_aux ts am mult unit t
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 247, "start_col": 0, "start_line": 242 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s let rec apply_swaps_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (ss:list (swap (length xs))): Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) = match ss with | [] -> () | s::ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss' let permute_via_swaps (p:permute) = (#a:Type) -> (am:amap a) -> xs:list atom -> Lemma (exists ss. p xs == apply_swaps xs ss) let permute_via_swaps_correct_aux (p:permute) (pvs:permute_via_swaps p) (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (p xs)) = pvs am xs; assert(exists ss. p xs == apply_swaps xs ss); exists_elim (xsdenote m am xs == xsdenote m am (p xs)) (() <: squash (exists ss. p xs == apply_swaps xs ss)) (fun ss -> apply_swaps_correct m am xs ss) let permute_via_swaps_correct (p:permute) (pvs:permute_via_swaps p) : permute_correct p = fun #a -> permute_via_swaps_correct_aux p pvs #a (***** Sorting atoms is a correct permutation (since it can be done by swaps) *) // Here we sort the variable numbers let sort : permute = List.Tot.Base.sortWith #nat (compare_of_bool (<)) let sort_via_swaps (#a:Type) (am : amap a) (xs:list atom) : Lemma (exists ss. sort xs == apply_swaps xs ss) = List.Tot.Properties.sortWith_permutation #nat (compare_of_bool (<)) xs; let ss = equal_counts_implies_swaps #nat xs (sort xs) in () let sort_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (sort xs)) = permute_via_swaps_correct sort (fun #a am -> sort_via_swaps am) m am xs let sort_correct : permute_correct sort = (fun #a -> sort_correct_aux #a) (***** Canonicalization tactics *) (* [@@plugin] *) let canon (e:exp) = sort (flatten e) let canon_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (canon e)) = flatten_correct m am e; sort_correct m am (flatten e) let monoid_reflect_orig (#a:Type) (m:cm a) (am:amap a) (e1 e2:exp) : Lemma (requires (xsdenote m am (canon e1) == xsdenote m am (canon e2))) (ensures (mdenote m am e1 == mdenote m am e2)) = canon_correct m am e1; canon_correct m am e2 let monoid_reflect (#a:Type) (m:cm a) (am:amap a) (e1 e2:exp) (_ : squash (xsdenote m am (canon e1) == xsdenote m am (canon e2))) : squash (mdenote m am e1 == mdenote m am e2) = canon_correct m am e1; canon_correct m am e2 (* Finds the position of first occurrence of x in xs. This is now specialized to terms and their funny term_eq. *) let rec where_aux (n:nat) (x:term) (xs:list term) : Tac (option nat) = match xs with | [] -> None | x'::xs' -> if term_eq x x' then Some n else where_aux (n+1) x xs' let where = where_aux 0 // This expects that mult, unit, and t have already been normalized let rec reification_aux (#a:Type) (ts:list term) (am:amap a) (mult unit t : term) : Tac (exp * list term * amap a) = let hd, tl = collect_app_ref t in let fatom (t:term) (ts:list term) (am:amap a) : Tac (exp * list term * amap a) = match where t ts with | Some v -> (Atom v, ts, am) | None -> let vfresh = length ts in let z = unquote t in (Atom vfresh, ts @ [t], update vfresh z am) in match inspect hd, list_unref tl with | Tv_FVar fv, [(t1, Q_Explicit) ; (t2, Q_Explicit)] -> if term_eq (pack (Tv_FVar fv)) mult then (let (e1,ts,am) = reification_aux ts am mult unit t1 in let (e2,ts,am) = reification_aux ts am mult unit t2 in (Mult e1 e2, ts, am)) else fatom t ts am | _, _ -> if term_eq t unit then (Unit, ts, am) else fatom t ts am
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.Algebra.CommMonoid.cm a -> ts: Prims.list FStar.Tactics.NamedView.term -> am: FStar.Tactics.CanonCommMonoidSimple.amap a -> t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac ((FStar.Tactics.CanonCommMonoidSimple.exp * Prims.list FStar.Tactics.NamedView.term) * FStar.Tactics.CanonCommMonoidSimple.amap a)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Algebra.CommMonoid.cm", "Prims.list", "FStar.Tactics.NamedView.term", "FStar.Tactics.CanonCommMonoidSimple.amap", "FStar.Tactics.CanonCommMonoidSimple.reification_aux", "FStar.Pervasives.Native.tuple3", "FStar.Tactics.CanonCommMonoidSimple.exp", "FStar.Tactics.V2.Derived.norm_term", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta", "FStar.Pervasives.zeta", "FStar.Pervasives.iota", "Prims.Nil", "FStar.Algebra.CommMonoid.__proj__CM__item__unit", "FStar.Stubs.Reflection.Types.term", "FStar.Algebra.CommMonoid.__proj__CM__item__mult" ]
[]
false
true
false
false
false
let reification (#a: Type) (m: cm a) (ts: list term) (am: amap a) (t: term) : Tac (exp * list term * amap a) =
let mult = norm_term [delta; zeta; iota] (quote (CM?.mult m)) in let unit = norm_term [delta; zeta; iota] (quote (CM?.unit m)) in let t = norm_term [delta; zeta; iota] t in reification_aux ts am mult unit t
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.flatten_correct_aux
val flatten_correct_aux (#a: Type) (m: cm a) (am: amap a) (xs1 xs2: list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2))
val flatten_correct_aux (#a: Type) (m: cm a) (am: amap a) (xs1 xs2: list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2))
let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2)
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 50, "end_line": 97, "start_col": 0, "start_line": 89 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.Algebra.CommMonoid.cm a -> am: FStar.Tactics.CanonCommMonoidSimple.amap a -> xs1: Prims.list FStar.Tactics.CanonCommMonoidSimple.atom -> xs2: Prims.list FStar.Tactics.CanonCommMonoidSimple.atom -> FStar.Pervasives.Lemma (ensures FStar.Tactics.CanonCommMonoidSimple.xsdenote m am (xs1 @ xs2) == CM?.mult m (FStar.Tactics.CanonCommMonoidSimple.xsdenote m am xs1) (FStar.Tactics.CanonCommMonoidSimple.xsdenote m am xs2))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Algebra.CommMonoid.cm", "FStar.Tactics.CanonCommMonoidSimple.amap", "Prims.list", "FStar.Tactics.CanonCommMonoidSimple.atom", "FStar.Algebra.CommMonoid.__proj__CM__item__identity", "FStar.Tactics.CanonCommMonoidSimple.xsdenote", "Prims.uu___is_Nil", "FStar.Algebra.CommMonoid.right_identity", "FStar.Tactics.CanonCommMonoidSimple.select", "Prims.bool", "Prims.unit", "FStar.Tactics.CanonCommMonoidSimple.flatten_correct_aux", "FStar.Algebra.CommMonoid.__proj__CM__item__associativity", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.List.Tot.Base.op_At", "FStar.Algebra.CommMonoid.__proj__CM__item__mult", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec flatten_correct_aux (#a: Type) (m: cm a) (am: amap a) (xs1 xs2: list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) =
match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x :: xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2)
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.where
val where : x: FStar.Tactics.NamedView.term -> xs: Prims.list FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option Prims.nat)
let where = where_aux 0
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 23, "end_line": 218, "start_col": 0, "start_line": 218 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s let rec apply_swaps_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (ss:list (swap (length xs))): Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) = match ss with | [] -> () | s::ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss' let permute_via_swaps (p:permute) = (#a:Type) -> (am:amap a) -> xs:list atom -> Lemma (exists ss. p xs == apply_swaps xs ss) let permute_via_swaps_correct_aux (p:permute) (pvs:permute_via_swaps p) (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (p xs)) = pvs am xs; assert(exists ss. p xs == apply_swaps xs ss); exists_elim (xsdenote m am xs == xsdenote m am (p xs)) (() <: squash (exists ss. p xs == apply_swaps xs ss)) (fun ss -> apply_swaps_correct m am xs ss) let permute_via_swaps_correct (p:permute) (pvs:permute_via_swaps p) : permute_correct p = fun #a -> permute_via_swaps_correct_aux p pvs #a (***** Sorting atoms is a correct permutation (since it can be done by swaps) *) // Here we sort the variable numbers let sort : permute = List.Tot.Base.sortWith #nat (compare_of_bool (<)) let sort_via_swaps (#a:Type) (am : amap a) (xs:list atom) : Lemma (exists ss. sort xs == apply_swaps xs ss) = List.Tot.Properties.sortWith_permutation #nat (compare_of_bool (<)) xs; let ss = equal_counts_implies_swaps #nat xs (sort xs) in () let sort_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (sort xs)) = permute_via_swaps_correct sort (fun #a am -> sort_via_swaps am) m am xs let sort_correct : permute_correct sort = (fun #a -> sort_correct_aux #a) (***** Canonicalization tactics *) (* [@@plugin] *) let canon (e:exp) = sort (flatten e) let canon_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (canon e)) = flatten_correct m am e; sort_correct m am (flatten e) let monoid_reflect_orig (#a:Type) (m:cm a) (am:amap a) (e1 e2:exp) : Lemma (requires (xsdenote m am (canon e1) == xsdenote m am (canon e2))) (ensures (mdenote m am e1 == mdenote m am e2)) = canon_correct m am e1; canon_correct m am e2 let monoid_reflect (#a:Type) (m:cm a) (am:amap a) (e1 e2:exp) (_ : squash (xsdenote m am (canon e1) == xsdenote m am (canon e2))) : squash (mdenote m am e1 == mdenote m am e2) = canon_correct m am e1; canon_correct m am e2 (* Finds the position of first occurrence of x in xs. This is now specialized to terms and their funny term_eq. *) let rec where_aux (n:nat) (x:term) (xs:list term) : Tac (option nat) = match xs with | [] -> None
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Tactics.NamedView.term -> xs: Prims.list FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option Prims.nat)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Tactics.CanonCommMonoidSimple.where_aux" ]
[]
false
true
false
false
false
let where =
where_aux 0
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.mdenote
val mdenote (#a: Type) (m: cm a) (am: amap a) (e: exp) : a
val mdenote (#a: Type) (m: cm a) (am: amap a) (e: exp) : a
let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2)
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 64, "end_line": 73, "start_col": 0, "start_line": 69 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.Algebra.CommMonoid.cm a -> am: FStar.Tactics.CanonCommMonoidSimple.amap a -> e: FStar.Tactics.CanonCommMonoidSimple.exp -> a
Prims.Tot
[ "total" ]
[]
[ "FStar.Algebra.CommMonoid.cm", "FStar.Tactics.CanonCommMonoidSimple.amap", "FStar.Tactics.CanonCommMonoidSimple.exp", "FStar.Algebra.CommMonoid.__proj__CM__item__unit", "FStar.Tactics.CanonCommMonoidSimple.atom", "FStar.Tactics.CanonCommMonoidSimple.select", "FStar.Algebra.CommMonoid.__proj__CM__item__mult", "FStar.Tactics.CanonCommMonoidSimple.mdenote" ]
[ "recursion" ]
false
false
false
true
false
let rec mdenote (#a: Type) (m: cm a) (am: amap a) (e: exp) : a =
match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2)
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.size_block
val size_block (a: Spec.alg) : x: size_t{v x = 16 * Spec.size_word a}
val size_block (a: Spec.alg) : x: size_t{v x = 16 * Spec.size_word a}
let size_block (a:Spec.alg) : x:size_t{v x = 16 * Spec.size_word a} = Spec.alg_inversion_lemma a; match a with | Spec.Blake2.Blake2S -> 64ul | Spec.Blake2.Blake2B -> 128ul
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 371, "start_col": 0, "start_line": 367 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a noextract inline_for_extraction let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a) noextract inline_for_extraction val zero_element: a:Spec.alg -> m:m_spec -> element_t a m noextract inline_for_extraction let row_len (a:Spec.alg) (m:m_spec) : size_t = match a,m with | Spec.Blake2S,M128 -> 1ul | Spec.Blake2S,M256 -> 1ul | Spec.Blake2B,M256 -> 1ul | _ -> 4ul noextract inline_for_extraction unfold let row_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (row_len a m) noextract inline_for_extraction val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) noextract val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m -> Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==> row_v h0 r1 == row_v h1 r2)) [SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)] noextract inline_for_extraction let salt_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noextract inline_for_extraction let personal_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noeq type blake2s_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint16; node_depth: uint8; inner_length: uint8; salt: lbuffer uint8 8ul; personal: lbuffer uint8 8ul; } inline_for_extraction noextract let get_blake2s_salt (p: blake2s_params) = p.salt inline_for_extraction noextract let get_blake2s_personal (p: blake2s_params) = p.personal inline_for_extraction noextract let set_blake2s_digest_length (p: blake2s_params) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S}) : blake2s_params = {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S}) : blake2s_params = {p with key_length = to_u8 kk} let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop = live h p.salt /\ live h p.personal let blake2s_params_loc (p: blake2s_params) = loc p.salt `union` loc p.personal let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params = Spec.Mkblake2s_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noeq type blake2b_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint32; node_depth: uint8; inner_length: uint8; // Blake2b also contains 14 reserved bytes here, but they seem // unused and to only contain zeros, hence we do not expose them salt: lbuffer uint8 16ul; personal: lbuffer uint8 16ul; } let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop = live h p.salt /\ live h p.personal let blake2b_params_loc (p: blake2b_params) = loc p.salt `union` loc p.personal let blake2b_params_v (h: mem) (p: blake2b_params): GTot Spec.blake2b_params = Spec.Mkblake2b_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noextract inline_for_extraction let blake2_params (a:Spec.alg) = match a with | Spec.Blake2S -> blake2s_params | Spec.Blake2B -> blake2b_params inline_for_extraction noextract let set_digest_length (#a: Spec.alg) (p: blake2_params a) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_digest_length p nn | Spec.Blake2B -> {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_key_length (#a: Spec.alg) (p: blake2_params a) (kk: size_t{v kk <= Spec.max_key a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_key_length p kk | Spec.Blake2B -> {p with key_length = to_u8 kk} inline_for_extraction noextract let get_salt (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (salt_len a) = match a with | Spec.Blake2S -> get_blake2s_salt p | Spec.Blake2B -> p.salt inline_for_extraction noextract let get_personal (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (personal_len a) = match a with | Spec.Blake2S -> get_blake2s_personal p | Spec.Blake2B -> p.personal noextract inline_for_extraction let blake2_params_inv (#a:Spec.alg) (h: mem) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_inv h p | Spec.Blake2B -> blake2b_params_inv h p noextract inline_for_extraction let blake2_params_loc (#a:Spec.alg) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_loc p | Spec.Blake2B -> blake2b_params_loc p noextract inline_for_extraction let blake2_params_v (#a:Spec.alg) (h: mem) (p: blake2_params a) : GTot (Spec.blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_v h p | Spec.Blake2B -> blake2b_params_v h p noextract inline_for_extraction val create_default_params: a:Spec.alg -> salt: lbuffer uint8 (salt_len a) -> personal: lbuffer uint8 (personal_len a) -> Stack (blake2_params a) (requires fun h -> live h salt /\ live h personal /\ as_seq h salt == Seq.create (Spec.salt_length a) (u8 0) /\ as_seq h personal == Seq.create (Spec.personal_length a) (u8 0) ) (ensures (fun h0 p h1 -> h0 == h1 /\ blake2_params_loc p == loc salt `union` loc personal /\ blake2_params_inv h1 p /\ blake2_params_v h1 p == Spec.blake2_default_params a)) noextract inline_for_extraction unfold let state_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (4ul *. row_len a m) noextract inline_for_extraction unfold let index_t = n:size_t{v n < 4} noextract inline_for_extraction let g_rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) : GTot (row_p a m) = gsub st (idx *. row_len a m) (row_len a m) val g_rowi_disjoint: #a:Spec.alg -> #m:m_spec -> st:state_p a m -> idx1:index_t -> idx2:index_t -> Lemma (ensures (v idx1 <> v idx2 ==> disjoint (g_rowi st idx1) (g_rowi st idx2))) [SMTPat (disjoint (g_rowi st idx1) (g_rowi st idx2))] val g_rowi_unchanged: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t -> Lemma (requires (as_seq h0 st == as_seq h1 st)) (ensures (as_seq h0 (g_rowi st i) == as_seq h1 (g_rowi st i))) [SMTPat (as_seq h0 (g_rowi st i)); SMTPat (as_seq h1 (g_rowi st i))] val g_rowi_disjoint_other: #a:Spec.alg -> #m:m_spec -> #b:Type -> st:state_p a m -> i:index_t -> x:buffer b -> Lemma(requires (disjoint st x)) (ensures (disjoint (g_rowi st i) x)) [SMTPat (disjoint (g_rowi st i) x)] inline_for_extraction noextract val state_v: #a:Spec.alg -> #m:m_spec -> mem -> state_p a m -> GTot (Spec.state a) noextract val state_v_eq_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> st1:state_p a m -> st2:state_p a m -> Lemma (requires (as_seq h0 st1 == as_seq h1 st2)) (ensures (state_v h0 st1 == state_v h1 st2)) [SMTPat (state_v #a #m h0 st1); SMTPat (state_v #a #m h1 st2)] noextract val state_v_rowi_lemma: #a:Spec.alg -> #m:m_spec -> h:mem -> st:state_p a m -> i:index_t -> Lemma (requires (live h st)) (ensures (Lib.Sequence.((state_v h st).[v i] == row_v h (g_rowi st i)))) [SMTPat (row_v h (g_rowi st i))] noextract val state_v_live_rowi_lemma: #a:Spec.alg -> #m:m_spec -> h:mem -> st:state_p a m -> i:index_t -> Lemma (requires (live h st)) (ensures (live h (g_rowi st i))) [SMTPat (live h (g_rowi st i))] noextract val modifies_one_row: a:Spec.alg -> m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t -> j:index_t -> Lemma (requires (live h0 st /\ modifies (loc (g_rowi st i)) h0 h1 /\ v i <> v j)) (ensures (row_v h1 (g_rowi st j) == row_v h0 (g_rowi st j))) [SMTPat (modifies (loc (g_rowi st i)) h0 h1); SMTPat (row_v h1 (g_rowi st j))] noextract val modifies_row_state: a:Spec.alg -> m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t -> Lemma (requires (live h0 st /\ modifies (loc (g_rowi st i)) h0 h1)) (ensures (modifies (loc st) h0 h1 /\ state_v h1 st == Lib.Sequence.((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))) [SMTPat (modifies (loc (g_rowi #a #m st i)) h0 h1)] noextract inline_for_extraction val rowi: #a:Spec.alg -> #m:m_spec -> st:state_p a m -> idx:index_t -> Stack (row_p a m) (requires (fun h -> live h st)) (ensures (fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == g_rowi st idx)) noextract inline_for_extraction val xor_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:row_p a m -> Stack unit (requires (fun h -> live h r1 /\ live h r2 /\ disjoint r1 r2)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( row_v h0 r1 ^| row_v h0 r2 ))) noextract inline_for_extraction val add_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:row_p a m -> Stack unit (requires (fun h -> live h r1 /\ live h r2 /\ disjoint r1 r2)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( row_v h0 r1 +| row_v h0 r2 ))) noextract inline_for_extraction val ror_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:rotval (Spec.wt a) -> Stack unit (requires (fun h -> live h r1)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( row_v h0 r1 >>>| r2 ))) noextract inline_for_extraction val permr_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> n:index_t -> Stack unit (requires (fun h -> live h r1)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( rotr (row_v h0 r1) (v n) ))) val create4_lemma: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a -> Lemma (ensures ( let l = [ x0; x1; x2; x3 ] in assert_norm (List.Tot.length l = 4); Lib.Sequence.createL l == Lib.Sequence.create4 x0 x1 x2 x3)) [SMTPat (Lib.Sequence.createL [x0;x1;x2;x3])] noextract inline_for_extraction val alloc_row: a:Spec.alg -> m:m_spec -> StackInline (row_p a m) (requires (fun h -> True)) (ensures (fun h0 r h1 -> stack_allocated r h0 h1 (Lib.Sequence.create (v (row_len a m)) (zero_element a m)) /\ live h1 r /\ row_v h1 r == Spec.zero_row a)) noextract inline_for_extraction val create_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> w0:word_t a -> w1:word_t a -> w2:word_t a -> w3:word_t a -> Stack unit (requires (fun h -> live h r1)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( create_row w0 w1 w2 w3 ))) noextract inline_for_extraction val load_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> ws:lbuffer (word_t a) 4ul -> Stack unit (requires (fun h -> live h r1 /\ live h ws /\ disjoint r1 ws)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( load_row (as_seq h0 ws)))) noextract inline_for_extraction let size_row al = 4ul *. size (Spec.size_word al) noextract inline_for_extraction val store_row: #a:Spec.alg -> #m:m_spec -> b:lbuffer uint8 (size_row a) -> r:row_p a m -> Stack unit (requires (fun h -> live h r /\ live h b /\ disjoint r b)) (ensures (fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Lib.ByteSequence.uints_to_bytes_le (row_v h0 r))) noextract inline_for_extraction val store_row32: #a:Spec.alg -> #m:m_spec -> b:lbuffer (word_t a) 4ul -> r:row_p a m -> Stack unit (requires (fun h -> live h r /\ live h b /\ disjoint r b)) (ensures (fun h0 _ h1 -> modifies (loc b) h0 h1 /\ Spec.( load_row (as_seq h1 b)) == row_v h0 r))
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Blake2.Definitions.alg -> x: Lib.IntTypes.size_t{Lib.IntTypes.v x = 16 * Spec.Blake2.Definitions.size_word a}
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.Mul.op_Star", "Spec.Blake2.Definitions.size_word", "Prims.unit", "Spec.Blake2.Definitions.alg_inversion_lemma" ]
[]
false
false
false
false
false
let size_block (a: Spec.alg) : x: size_t{v x = 16 * Spec.size_word a} =
Spec.alg_inversion_lemma a; match a with | Spec.Blake2.Blake2S -> 64ul | Spec.Blake2.Blake2B -> 128ul
false
Hacl.Impl.Blake2.Core.fsti
Hacl.Impl.Blake2.Core.g_rowi
val g_rowi (#a: Spec.alg) (#m: m_spec) (st: state_p a m) (idx: index_t) : GTot (row_p a m)
val g_rowi (#a: Spec.alg) (#m: m_spec) (st: state_p a m) (idx: index_t) : GTot (row_p a m)
let g_rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) : GTot (row_p a m) = gsub st (idx *. row_len a m) (row_len a m)
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 44, "end_line": 238, "start_col": 0, "start_line": 237 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" type m_spec = | M32 | M128 | M256 noextract inline_for_extraction type word_t (a:Spec.alg) = Spec.word_t a noextract inline_for_extraction let element_t (a:Spec.alg) (m:m_spec) = match a,m with | Spec.Blake2S,M128 -> (vec_t U32 4) | Spec.Blake2S,M256 -> (vec_t U32 4) | Spec.Blake2B,M256 -> (vec_t U64 4) | _ -> (word_t a) noextract inline_for_extraction val zero_element: a:Spec.alg -> m:m_spec -> element_t a m noextract inline_for_extraction let row_len (a:Spec.alg) (m:m_spec) : size_t = match a,m with | Spec.Blake2S,M128 -> 1ul | Spec.Blake2S,M256 -> 1ul | Spec.Blake2B,M256 -> 1ul | _ -> 4ul noextract inline_for_extraction unfold let row_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (row_len a m) noextract inline_for_extraction val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) noextract val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m -> Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==> row_v h0 r1 == row_v h1 r2)) [SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)] noextract inline_for_extraction let salt_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noextract inline_for_extraction let personal_len (a:Spec.alg) : size_t = match a with | Spec.Blake2S -> 8ul | Spec.Blake2B -> 16ul noeq type blake2s_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint16; node_depth: uint8; inner_length: uint8; salt: lbuffer uint8 8ul; personal: lbuffer uint8 8ul; } inline_for_extraction noextract let get_blake2s_salt (p: blake2s_params) = p.salt inline_for_extraction noextract let get_blake2s_personal (p: blake2s_params) = p.personal inline_for_extraction noextract let set_blake2s_digest_length (p: blake2s_params) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S}) : blake2s_params = {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S}) : blake2s_params = {p with key_length = to_u8 kk} let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop = live h p.salt /\ live h p.personal let blake2s_params_loc (p: blake2s_params) = loc p.salt `union` loc p.personal let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params = Spec.Mkblake2s_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noeq type blake2b_params = { digest_length: uint8; key_length: uint8; fanout: uint8; depth: uint8; leaf_length: uint32; node_offset: uint32; xof_length: uint32; node_depth: uint8; inner_length: uint8; // Blake2b also contains 14 reserved bytes here, but they seem // unused and to only contain zeros, hence we do not expose them salt: lbuffer uint8 16ul; personal: lbuffer uint8 16ul; } let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop = live h p.salt /\ live h p.personal let blake2b_params_loc (p: blake2b_params) = loc p.salt `union` loc p.personal let blake2b_params_v (h: mem) (p: blake2b_params): GTot Spec.blake2b_params = Spec.Mkblake2b_params p.digest_length p.key_length p.fanout p.depth p.leaf_length p.node_offset p.xof_length p.node_depth p.inner_length (as_seq h p.salt) (as_seq h p.personal) noextract inline_for_extraction let blake2_params (a:Spec.alg) = match a with | Spec.Blake2S -> blake2s_params | Spec.Blake2B -> blake2b_params inline_for_extraction noextract let set_digest_length (#a: Spec.alg) (p: blake2_params a) (nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_digest_length p nn | Spec.Blake2B -> {p with digest_length = to_u8 nn} inline_for_extraction noextract let set_key_length (#a: Spec.alg) (p: blake2_params a) (kk: size_t{v kk <= Spec.max_key a}) : blake2_params a = match a with | Spec.Blake2S -> set_blake2s_key_length p kk | Spec.Blake2B -> {p with key_length = to_u8 kk} inline_for_extraction noextract let get_salt (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (salt_len a) = match a with | Spec.Blake2S -> get_blake2s_salt p | Spec.Blake2B -> p.salt inline_for_extraction noextract let get_personal (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (personal_len a) = match a with | Spec.Blake2S -> get_blake2s_personal p | Spec.Blake2B -> p.personal noextract inline_for_extraction let blake2_params_inv (#a:Spec.alg) (h: mem) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_inv h p | Spec.Blake2B -> blake2b_params_inv h p noextract inline_for_extraction let blake2_params_loc (#a:Spec.alg) (p: blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_loc p | Spec.Blake2B -> blake2b_params_loc p noextract inline_for_extraction let blake2_params_v (#a:Spec.alg) (h: mem) (p: blake2_params a) : GTot (Spec.blake2_params a) = match a with | Spec.Blake2S -> blake2s_params_v h p | Spec.Blake2B -> blake2b_params_v h p noextract inline_for_extraction val create_default_params: a:Spec.alg -> salt: lbuffer uint8 (salt_len a) -> personal: lbuffer uint8 (personal_len a) -> Stack (blake2_params a) (requires fun h -> live h salt /\ live h personal /\ as_seq h salt == Seq.create (Spec.salt_length a) (u8 0) /\ as_seq h personal == Seq.create (Spec.personal_length a) (u8 0) ) (ensures (fun h0 p h1 -> h0 == h1 /\ blake2_params_loc p == loc salt `union` loc personal /\ blake2_params_inv h1 p /\ blake2_params_v h1 p == Spec.blake2_default_params a)) noextract inline_for_extraction unfold let state_p (a:Spec.alg) (m:m_spec) = lbuffer (element_t a m) (4ul *. row_len a m) noextract inline_for_extraction unfold let index_t = n:size_t{v n < 4}
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Blake2.Core.fsti" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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": 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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
st: Hacl.Impl.Blake2.Core.state_p a m -> idx: Hacl.Impl.Blake2.Core.index_t -> Prims.GTot (Hacl.Impl.Blake2.Core.row_p a m)
Prims.GTot
[ "sometrivial" ]
[]
[ "Spec.Blake2.Definitions.alg", "Hacl.Impl.Blake2.Core.m_spec", "Hacl.Impl.Blake2.Core.state_p", "Hacl.Impl.Blake2.Core.index_t", "Lib.Buffer.gsub", "Lib.Buffer.MUT", "Hacl.Impl.Blake2.Core.element_t", "Lib.IntTypes.op_Star_Dot", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Blake2.Core.row_len", "Hacl.Impl.Blake2.Core.row_p" ]
[]
false
false
false
false
false
let g_rowi (#a: Spec.alg) (#m: m_spec) (st: state_p a m) (idx: index_t) : GTot (row_p a m) =
gsub st (idx *. row_len a m) (row_len a m)
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.flatten
val flatten (e: exp) : list atom
val flatten (e: exp) : list atom
let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 41, "end_line": 87, "start_col": 0, "start_line": 83 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: FStar.Tactics.CanonCommMonoidSimple.exp -> Prims.list FStar.Tactics.CanonCommMonoidSimple.atom
Prims.Tot
[ "total" ]
[]
[ "FStar.Tactics.CanonCommMonoidSimple.exp", "Prims.Nil", "FStar.Tactics.CanonCommMonoidSimple.atom", "Prims.Cons", "FStar.List.Tot.Base.op_At", "FStar.Tactics.CanonCommMonoidSimple.flatten", "Prims.list" ]
[ "recursion" ]
false
false
false
true
false
let rec flatten (e: exp) : list atom =
match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.xsdenote
val xsdenote (#a: Type) (m: cm a) (am: amap a) (xs: list atom) : a
val xsdenote (#a: Type) (m: cm a) (am: amap a) (xs: list atom) : a
let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs')
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 58, "end_line": 79, "start_col": 0, "start_line": 75 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.Algebra.CommMonoid.cm a -> am: FStar.Tactics.CanonCommMonoidSimple.amap a -> xs: Prims.list FStar.Tactics.CanonCommMonoidSimple.atom -> a
Prims.Tot
[ "total" ]
[]
[ "FStar.Algebra.CommMonoid.cm", "FStar.Tactics.CanonCommMonoidSimple.amap", "Prims.list", "FStar.Tactics.CanonCommMonoidSimple.atom", "FStar.Algebra.CommMonoid.__proj__CM__item__unit", "FStar.Tactics.CanonCommMonoidSimple.select", "FStar.Algebra.CommMonoid.__proj__CM__item__mult", "FStar.Tactics.CanonCommMonoidSimple.xsdenote" ]
[ "recursion" ]
false
false
false
true
false
let rec xsdenote (#a: Type) (m: cm a) (am: amap a) (xs: list atom) : a =
match xs with | [] -> CM?.unit m | [x] -> select x am | x :: xs' -> CM?.mult m (select x am) (xsdenote m am xs')
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.canon_monoid
val canon_monoid (#a: Type) (m: cm a) : Tac unit
val canon_monoid (#a: Type) (m: cm a) : Tac unit
let canon_monoid (#a:Type) (m:cm a) : Tac unit = norm []; match term_as_formula (cur_goal ()) with | Comp (Eq (Some t)) t1 t2 -> // dump ("t1 =" ^ term_to_string t1 ^ // "; t2 =" ^ term_to_string t2); if term_eq t (quote a) then let (r1, ts, am) = reification m [] (const (CM?.unit m)) t1 in let (r2, _, am) = reification m ts am t2 in dump ("am =" ^ term_to_string (quote am)); change_sq (quote (mdenote m am r1 == mdenote m am r2)); // dump ("before =" ^ term_to_string (norm_term [delta;primops] // (quote (mdenote m am r1 == mdenote m am r2)))); // dump ("expected after =" ^ term_to_string (norm_term [delta;primops] // (quote (xsdenote m am (canon r1) == // xsdenote m am (canon r2))))); apply (`monoid_reflect); // dump ("after apply"); norm [delta_only [`%canon; `%xsdenote; `%flatten; `%sort; `%select; `%assoc; `%fst; `%__proj__Mktuple2__item___1; `%(@); `%append; `%List.Tot.sortWith; `%List.Tot.partition; `%bool_of_compare; `%compare_of_bool; ]; primops] // ;dump "done" else fail "Goal should be an equality at the right monoid type" | _ -> fail "Goal should be an equality"
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 42, "end_line": 274, "start_col": 0, "start_line": 249 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s let rec apply_swaps_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (ss:list (swap (length xs))): Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) = match ss with | [] -> () | s::ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss' let permute_via_swaps (p:permute) = (#a:Type) -> (am:amap a) -> xs:list atom -> Lemma (exists ss. p xs == apply_swaps xs ss) let permute_via_swaps_correct_aux (p:permute) (pvs:permute_via_swaps p) (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (p xs)) = pvs am xs; assert(exists ss. p xs == apply_swaps xs ss); exists_elim (xsdenote m am xs == xsdenote m am (p xs)) (() <: squash (exists ss. p xs == apply_swaps xs ss)) (fun ss -> apply_swaps_correct m am xs ss) let permute_via_swaps_correct (p:permute) (pvs:permute_via_swaps p) : permute_correct p = fun #a -> permute_via_swaps_correct_aux p pvs #a (***** Sorting atoms is a correct permutation (since it can be done by swaps) *) // Here we sort the variable numbers let sort : permute = List.Tot.Base.sortWith #nat (compare_of_bool (<)) let sort_via_swaps (#a:Type) (am : amap a) (xs:list atom) : Lemma (exists ss. sort xs == apply_swaps xs ss) = List.Tot.Properties.sortWith_permutation #nat (compare_of_bool (<)) xs; let ss = equal_counts_implies_swaps #nat xs (sort xs) in () let sort_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (sort xs)) = permute_via_swaps_correct sort (fun #a am -> sort_via_swaps am) m am xs let sort_correct : permute_correct sort = (fun #a -> sort_correct_aux #a) (***** Canonicalization tactics *) (* [@@plugin] *) let canon (e:exp) = sort (flatten e) let canon_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (canon e)) = flatten_correct m am e; sort_correct m am (flatten e) let monoid_reflect_orig (#a:Type) (m:cm a) (am:amap a) (e1 e2:exp) : Lemma (requires (xsdenote m am (canon e1) == xsdenote m am (canon e2))) (ensures (mdenote m am e1 == mdenote m am e2)) = canon_correct m am e1; canon_correct m am e2 let monoid_reflect (#a:Type) (m:cm a) (am:amap a) (e1 e2:exp) (_ : squash (xsdenote m am (canon e1) == xsdenote m am (canon e2))) : squash (mdenote m am e1 == mdenote m am e2) = canon_correct m am e1; canon_correct m am e2 (* Finds the position of first occurrence of x in xs. This is now specialized to terms and their funny term_eq. *) let rec where_aux (n:nat) (x:term) (xs:list term) : Tac (option nat) = match xs with | [] -> None | x'::xs' -> if term_eq x x' then Some n else where_aux (n+1) x xs' let where = where_aux 0 // This expects that mult, unit, and t have already been normalized let rec reification_aux (#a:Type) (ts:list term) (am:amap a) (mult unit t : term) : Tac (exp * list term * amap a) = let hd, tl = collect_app_ref t in let fatom (t:term) (ts:list term) (am:amap a) : Tac (exp * list term * amap a) = match where t ts with | Some v -> (Atom v, ts, am) | None -> let vfresh = length ts in let z = unquote t in (Atom vfresh, ts @ [t], update vfresh z am) in match inspect hd, list_unref tl with | Tv_FVar fv, [(t1, Q_Explicit) ; (t2, Q_Explicit)] -> if term_eq (pack (Tv_FVar fv)) mult then (let (e1,ts,am) = reification_aux ts am mult unit t1 in let (e2,ts,am) = reification_aux ts am mult unit t2 in (Mult e1 e2, ts, am)) else fatom t ts am | _, _ -> if term_eq t unit then (Unit, ts, am) else fatom t ts am let reification (#a:Type) (m:cm a) (ts:list term) (am:amap a) (t:term) : Tac (exp * list term * amap a) = let mult = norm_term [delta;zeta;iota] (quote (CM?.mult m)) in let unit = norm_term [delta;zeta;iota] (quote (CM?.unit m)) in let t = norm_term [delta;zeta;iota] t in reification_aux ts am mult unit t
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.Algebra.CommMonoid.cm a -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Algebra.CommMonoid.cm", "FStar.Stubs.Reflection.Types.typ", "FStar.Tactics.NamedView.term", "FStar.Tactics.CanonCommMonoidSimple.exp", "Prims.list", "FStar.Tactics.CanonCommMonoidSimple.amap", "FStar.Stubs.Tactics.V2.Builtins.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_only", "Prims.string", "Prims.Nil", "FStar.Pervasives.primops", "Prims.unit", "FStar.Tactics.V2.Derived.apply", "FStar.Tactics.V2.Derived.change_sq", "Prims.eq2", "FStar.Tactics.CanonCommMonoidSimple.mdenote", "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.CanonCommMonoidSimple.dump", "Prims.op_Hat", "FStar.Stubs.Tactics.V2.Builtins.term_to_string", "FStar.Pervasives.Native.tuple3", "FStar.Tactics.CanonCommMonoidSimple.reification", "FStar.Tactics.CanonCommMonoidSimple.const", "FStar.Algebra.CommMonoid.__proj__CM__item__unit", "Prims.bool", "FStar.Tactics.V2.Derived.fail", "FStar.Tactics.CanonCommMonoidSimple.term_eq", "FStar.Reflection.V2.Formula.formula", "FStar.Reflection.V2.Formula.term_as_formula", "FStar.Tactics.V2.Derived.cur_goal" ]
[]
false
true
false
false
false
let canon_monoid (#a: Type) (m: cm a) : Tac unit =
norm []; match term_as_formula (cur_goal ()) with | Comp (Eq (Some t)) t1 t2 -> if term_eq t (quote a) then let r1, ts, am = reification m [] (const (CM?.unit m)) t1 in let r2, _, am = reification m ts am t2 in dump ("am =" ^ term_to_string (quote am)); change_sq (quote (mdenote m am r1 == mdenote m am r2)); apply (`monoid_reflect); norm [ delta_only [ `%canon; `%xsdenote; `%flatten; `%sort; `%select; `%assoc; `%fst; `%__proj__Mktuple2__item___1; `%( @ ); `%append; `%List.Tot.sortWith; `%List.Tot.partition; `%bool_of_compare; `%compare_of_bool ]; primops ] else fail "Goal should be an equality at the right monoid type" | _ -> fail "Goal should be an equality"
false
CQueue.fst
CQueue.intro_vconst
val intro_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened emp (fun _ -> vconst x) (fun _ -> True) (fun _ _ h' -> h' (vconst x) == x)
val intro_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened emp (fun _ -> vconst x) (fun _ -> True) (fun _ _ h' -> h' (vconst x) == x)
let intro_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened emp (fun _ -> vconst x) (fun _ -> True) (fun _ _ h' -> h' (vconst x) == x) = change_slprop_rel emp (vconst x) (fun _ y -> y == x) (fun _ -> ())
{ "file_name": "share/steel/examples/steel/CQueue.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 17, "end_line": 66, "start_col": 0, "start_line": 52 }
module CQueue open CQueue.LList #set-options "--ide_id_info_off" //Re-define squash, since this module explicitly //replies on proving equalities of the form `t_of v == squash p` //which are delicate in the presence of optimizations that //unfold `Prims.squash (p /\ q)`to _:unit{p /\ q} //See Issue #2496 let squash (p:Type u#a) : Type0 = squash p (* BEGIN library *) let intro_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: (t_of v) -> GTot t) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v)) = intro_vrewrite v f let elim_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened (vrewrite v f) (fun _ -> v) (fun _ -> True) (fun h _ h' -> h (vrewrite v f) == f (h' v)) = elim_vrewrite v f let vconst_sel (#a: Type) (x: a) : Tot (selector a (hp_of emp)) = fun _ -> x [@@ __steel_reduce__] let vconst' (#a: Type) (x: a) : GTot vprop' = { hp = hp_of emp; t = a; sel = vconst_sel x; } [@@ __steel_reduce__] let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "CQueue.LList.fsti.checked" ], "interface_file": true, "source_file": "CQueue.fst" }
[ { "abbrev": false, "full_module": "CQueue.LList", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> Steel.Effect.Atomic.SteelGhost Prims.unit
Steel.Effect.Atomic.SteelGhost
[]
[]
[ "Steel.Memory.inames", "Steel.Effect.Atomic.change_slprop_rel", "Steel.Effect.Common.emp", "CQueue.vconst", "Steel.Effect.Common.normal", "Steel.Effect.Common.t_of", "Prims.eq2", "Prims.prop", "Steel.Memory.mem", "Prims.unit", "Steel.Effect.Common.vprop", "Steel.Effect.Common.rmem", "Prims.l_True" ]
[]
false
true
false
false
false
let intro_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened emp (fun _ -> vconst x) (fun _ -> True) (fun _ _ h' -> h' (vconst x) == x) =
change_slprop_rel emp (vconst x) (fun _ y -> y == x) (fun _ -> ())
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.lem0
val lem0 : a: Prims.int -> b: Prims.int -> c: Prims.int -> d: Prims.int -> Prims.unit
let lem0 (a b c d : int) = assert_by_tactic (0 + 1 + a + b + c + d + 2 == (b + 0) + 2 + d + (c + a + 0) + 1) (fun _ -> canon_monoid int_plus_cm; trefl())
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 46, "end_line": 280, "start_col": 0, "start_line": 278 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s let rec apply_swaps_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (ss:list (swap (length xs))): Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) = match ss with | [] -> () | s::ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss' let permute_via_swaps (p:permute) = (#a:Type) -> (am:amap a) -> xs:list atom -> Lemma (exists ss. p xs == apply_swaps xs ss) let permute_via_swaps_correct_aux (p:permute) (pvs:permute_via_swaps p) (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (p xs)) = pvs am xs; assert(exists ss. p xs == apply_swaps xs ss); exists_elim (xsdenote m am xs == xsdenote m am (p xs)) (() <: squash (exists ss. p xs == apply_swaps xs ss)) (fun ss -> apply_swaps_correct m am xs ss) let permute_via_swaps_correct (p:permute) (pvs:permute_via_swaps p) : permute_correct p = fun #a -> permute_via_swaps_correct_aux p pvs #a (***** Sorting atoms is a correct permutation (since it can be done by swaps) *) // Here we sort the variable numbers let sort : permute = List.Tot.Base.sortWith #nat (compare_of_bool (<)) let sort_via_swaps (#a:Type) (am : amap a) (xs:list atom) : Lemma (exists ss. sort xs == apply_swaps xs ss) = List.Tot.Properties.sortWith_permutation #nat (compare_of_bool (<)) xs; let ss = equal_counts_implies_swaps #nat xs (sort xs) in () let sort_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (sort xs)) = permute_via_swaps_correct sort (fun #a am -> sort_via_swaps am) m am xs let sort_correct : permute_correct sort = (fun #a -> sort_correct_aux #a) (***** Canonicalization tactics *) (* [@@plugin] *) let canon (e:exp) = sort (flatten e) let canon_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (canon e)) = flatten_correct m am e; sort_correct m am (flatten e) let monoid_reflect_orig (#a:Type) (m:cm a) (am:amap a) (e1 e2:exp) : Lemma (requires (xsdenote m am (canon e1) == xsdenote m am (canon e2))) (ensures (mdenote m am e1 == mdenote m am e2)) = canon_correct m am e1; canon_correct m am e2 let monoid_reflect (#a:Type) (m:cm a) (am:amap a) (e1 e2:exp) (_ : squash (xsdenote m am (canon e1) == xsdenote m am (canon e2))) : squash (mdenote m am e1 == mdenote m am e2) = canon_correct m am e1; canon_correct m am e2 (* Finds the position of first occurrence of x in xs. This is now specialized to terms and their funny term_eq. *) let rec where_aux (n:nat) (x:term) (xs:list term) : Tac (option nat) = match xs with | [] -> None | x'::xs' -> if term_eq x x' then Some n else where_aux (n+1) x xs' let where = where_aux 0 // This expects that mult, unit, and t have already been normalized let rec reification_aux (#a:Type) (ts:list term) (am:amap a) (mult unit t : term) : Tac (exp * list term * amap a) = let hd, tl = collect_app_ref t in let fatom (t:term) (ts:list term) (am:amap a) : Tac (exp * list term * amap a) = match where t ts with | Some v -> (Atom v, ts, am) | None -> let vfresh = length ts in let z = unquote t in (Atom vfresh, ts @ [t], update vfresh z am) in match inspect hd, list_unref tl with | Tv_FVar fv, [(t1, Q_Explicit) ; (t2, Q_Explicit)] -> if term_eq (pack (Tv_FVar fv)) mult then (let (e1,ts,am) = reification_aux ts am mult unit t1 in let (e2,ts,am) = reification_aux ts am mult unit t2 in (Mult e1 e2, ts, am)) else fatom t ts am | _, _ -> if term_eq t unit then (Unit, ts, am) else fatom t ts am let reification (#a:Type) (m:cm a) (ts:list term) (am:amap a) (t:term) : Tac (exp * list term * amap a) = let mult = norm_term [delta;zeta;iota] (quote (CM?.mult m)) in let unit = norm_term [delta;zeta;iota] (quote (CM?.unit m)) in let t = norm_term [delta;zeta;iota] t in reification_aux ts am mult unit t let canon_monoid (#a:Type) (m:cm a) : Tac unit = norm []; match term_as_formula (cur_goal ()) with | Comp (Eq (Some t)) t1 t2 -> // dump ("t1 =" ^ term_to_string t1 ^ // "; t2 =" ^ term_to_string t2); if term_eq t (quote a) then let (r1, ts, am) = reification m [] (const (CM?.unit m)) t1 in let (r2, _, am) = reification m ts am t2 in dump ("am =" ^ term_to_string (quote am)); change_sq (quote (mdenote m am r1 == mdenote m am r2)); // dump ("before =" ^ term_to_string (norm_term [delta;primops] // (quote (mdenote m am r1 == mdenote m am r2)))); // dump ("expected after =" ^ term_to_string (norm_term [delta;primops] // (quote (xsdenote m am (canon r1) == // xsdenote m am (canon r2))))); apply (`monoid_reflect); // dump ("after apply"); norm [delta_only [`%canon; `%xsdenote; `%flatten; `%sort; `%select; `%assoc; `%fst; `%__proj__Mktuple2__item___1; `%(@); `%append; `%List.Tot.sortWith; `%List.Tot.partition; `%bool_of_compare; `%compare_of_bool; ]; primops] // ;dump "done" else fail "Goal should be an equality at the right monoid type" | _ -> fail "Goal should be an equality" (***** Example *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Prims.int -> b: Prims.int -> c: Prims.int -> d: Prims.int -> Prims.unit
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "FStar.Tactics.Effect.assert_by_tactic", "Prims.eq2", "Prims.op_Addition", "Prims.unit", "FStar.Tactics.V2.Derived.trefl", "FStar.Tactics.CanonCommMonoidSimple.canon_monoid", "FStar.Algebra.CommMonoid.int_plus_cm" ]
[]
false
false
false
true
false
let lem0 (a b c d: int) =
assert_by_tactic (0 + 1 + a + b + c + d + 2 == (b + 0) + 2 + d + (c + a + 0) + 1) (fun _ -> canon_monoid int_plus_cm; trefl ())
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.apply_swap_correct
val apply_swap_correct (#a: Type) (m: cm a) (am: amap a) (xs: list atom) (s: swap (length xs)) : Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs)
val apply_swap_correct (#a: Type) (m: cm a) (am: amap a) (xs: list atom) (s: swap (length xs)) : Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs)
let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 61, "end_line": 143, "start_col": 0, "start_line": 140 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.Algebra.CommMonoid.cm a -> am: FStar.Tactics.CanonCommMonoidSimple.amap a -> xs: Prims.list FStar.Tactics.CanonCommMonoidSimple.atom -> s: FStar.Tactics.CanonCommSwaps.swap (FStar.List.Tot.Base.length xs) -> FStar.Pervasives.Lemma (ensures FStar.Tactics.CanonCommMonoidSimple.xsdenote m am xs == FStar.Tactics.CanonCommMonoidSimple.xsdenote m am (FStar.Tactics.CanonCommSwaps.apply_swap xs s)) (decreases xs)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "FStar.Algebra.CommMonoid.cm", "FStar.Tactics.CanonCommMonoidSimple.amap", "Prims.list", "FStar.Tactics.CanonCommMonoidSimple.atom", "FStar.Tactics.CanonCommSwaps.swap", "FStar.List.Tot.Base.length", "FStar.Tactics.CanonCommMonoidSimple.apply_swap_aux_correct", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Tactics.CanonCommMonoidSimple.xsdenote", "FStar.Tactics.CanonCommSwaps.apply_swap", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let apply_swap_correct (#a: Type) (m: cm a) (am: amap a) (xs: list atom) (s: swap (length xs)) : Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) =
apply_swap_aux_correct 0 m am xs s
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.apply_swaps_correct
val apply_swaps_correct (#a: Type) (m: cm a) (am: amap a) (xs: list atom) (ss: list (swap (length xs))) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss)
val apply_swaps_correct (#a: Type) (m: cm a) (am: amap a) (xs: list atom) (ss: list (swap (length xs))) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss)
let rec apply_swaps_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (ss:list (swap (length xs))): Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) = match ss with | [] -> () | s::ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss'
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 60, "end_line": 153, "start_col": 0, "start_line": 145 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.Algebra.CommMonoid.cm a -> am: FStar.Tactics.CanonCommMonoidSimple.amap a -> xs: Prims.list FStar.Tactics.CanonCommMonoidSimple.atom -> ss: Prims.list (FStar.Tactics.CanonCommSwaps.swap (FStar.List.Tot.Base.length xs)) -> FStar.Pervasives.Lemma (ensures FStar.Tactics.CanonCommMonoidSimple.xsdenote m am xs == FStar.Tactics.CanonCommMonoidSimple.xsdenote m am (FStar.Tactics.CanonCommSwaps.apply_swaps xs ss)) (decreases ss)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "FStar.Algebra.CommMonoid.cm", "FStar.Tactics.CanonCommMonoidSimple.amap", "Prims.list", "FStar.Tactics.CanonCommMonoidSimple.atom", "FStar.Tactics.CanonCommSwaps.swap", "FStar.List.Tot.Base.length", "FStar.Tactics.CanonCommMonoidSimple.apply_swaps_correct", "FStar.Tactics.CanonCommSwaps.apply_swap", "Prims.unit", "FStar.Tactics.CanonCommMonoidSimple.apply_swap_correct", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Tactics.CanonCommMonoidSimple.xsdenote", "FStar.Tactics.CanonCommSwaps.apply_swaps", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec apply_swaps_correct (#a: Type) (m: cm a) (am: amap a) (xs: list atom) (ss: list (swap (length xs))) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) =
match ss with | [] -> () | s :: ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss'
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.sort_via_swaps
val sort_via_swaps (#a: Type) (am: amap a) (xs: list atom) : Lemma (exists ss. sort xs == apply_swaps xs ss)
val sort_via_swaps (#a: Type) (am: amap a) (xs: list atom) : Lemma (exists ss. sort xs == apply_swaps xs ss)
let sort_via_swaps (#a:Type) (am : amap a) (xs:list atom) : Lemma (exists ss. sort xs == apply_swaps xs ss) = List.Tot.Properties.sortWith_permutation #nat (compare_of_bool (<)) xs; let ss = equal_counts_implies_swaps #nat xs (sort xs) in ()
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 4, "end_line": 184, "start_col": 0, "start_line": 179 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s let rec apply_swaps_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (ss:list (swap (length xs))): Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) = match ss with | [] -> () | s::ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss' let permute_via_swaps (p:permute) = (#a:Type) -> (am:amap a) -> xs:list atom -> Lemma (exists ss. p xs == apply_swaps xs ss) let permute_via_swaps_correct_aux (p:permute) (pvs:permute_via_swaps p) (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (p xs)) = pvs am xs; assert(exists ss. p xs == apply_swaps xs ss); exists_elim (xsdenote m am xs == xsdenote m am (p xs)) (() <: squash (exists ss. p xs == apply_swaps xs ss)) (fun ss -> apply_swaps_correct m am xs ss) let permute_via_swaps_correct (p:permute) (pvs:permute_via_swaps p) : permute_correct p = fun #a -> permute_via_swaps_correct_aux p pvs #a (***** Sorting atoms is a correct permutation (since it can be done by swaps) *) // Here we sort the variable numbers let sort : permute = List.Tot.Base.sortWith #nat (compare_of_bool (<))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
am: FStar.Tactics.CanonCommMonoidSimple.amap a -> xs: Prims.list FStar.Tactics.CanonCommMonoidSimple.atom -> FStar.Pervasives.Lemma (ensures exists (ss: Prims.list (FStar.Tactics.CanonCommSwaps.swap (FStar.List.Tot.Base.length xs))). FStar.Tactics.CanonCommMonoidSimple.sort xs == FStar.Tactics.CanonCommSwaps.apply_swaps xs ss)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Tactics.CanonCommMonoidSimple.amap", "Prims.list", "FStar.Tactics.CanonCommMonoidSimple.atom", "FStar.Tactics.CanonCommSwaps.swap", "FStar.List.Tot.Base.length", "Prims.nat", "FStar.Tactics.CanonCommSwaps.equal_counts_implies_swaps", "FStar.Tactics.CanonCommMonoidSimple.sort", "Prims.unit", "FStar.List.Tot.Properties.sortWith_permutation", "FStar.List.Tot.Base.compare_of_bool", "Prims.int", "Prims.op_LessThan", "Prims.l_True", "Prims.squash", "Prims.l_Exists", "Prims.eq2", "FStar.Tactics.CanonCommSwaps.apply_swaps", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let sort_via_swaps (#a: Type) (am: amap a) (xs: list atom) : Lemma (exists ss. sort xs == apply_swaps xs ss) =
List.Tot.Properties.sortWith_permutation #nat (compare_of_bool ( < )) xs; let ss = equal_counts_implies_swaps #nat xs (sort xs) in ()
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.apply_swap_aux_correct
val apply_swap_aux_correct (#a: Type) (n: nat) (m: cm a) (am: amap a) (xs: list atom) (s: swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs)
val apply_swap_aux_correct (#a: Type) (n: nat) (m: cm a) (am: amap a) (xs: list atom) (s: swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs)
let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 58, "end_line": 138, "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.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> m: FStar.Algebra.CommMonoid.cm a -> am: FStar.Tactics.CanonCommMonoidSimple.amap a -> xs: Prims.list FStar.Tactics.CanonCommMonoidSimple.atom -> s: FStar.Tactics.CanonCommSwaps.swap (FStar.List.Tot.Base.length xs + n) -> FStar.Pervasives.Lemma (ensures FStar.Tactics.CanonCommMonoidSimple.xsdenote m am xs == FStar.Tactics.CanonCommMonoidSimple.xsdenote m am (FStar.Tactics.CanonCommSwaps.apply_swap_aux n xs s)) (decreases xs)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Prims.nat", "FStar.Algebra.CommMonoid.cm", "FStar.Tactics.CanonCommMonoidSimple.amap", "Prims.list", "FStar.Tactics.CanonCommMonoidSimple.atom", "FStar.Tactics.CanonCommSwaps.swap", "Prims.op_Addition", "FStar.List.Tot.Base.length", "Prims.op_Equality", "FStar.Algebra.CommMonoid.__proj__CM__item__commutativity", "FStar.Tactics.CanonCommMonoidSimple.select", "Prims.unit", "FStar.Tactics.CanonCommMonoidSimple.xsdenote", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Algebra.CommMonoid.__proj__CM__item__mult", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Algebra.CommMonoid.__proj__CM__item__associativity", "Prims.bool", "FStar.Tactics.CanonCommMonoidSimple.apply_swap_aux_correct", "Prims.Cons", "FStar.Tactics.CanonCommSwaps.apply_swap_aux" ]
[ "recursion" ]
false
false
true
false
false
let rec apply_swap_aux_correct (#a: Type) (n: nat) (m: cm a) (am: amap a) (xs: list atom) (s: swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) =
match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n + 1) m am (x2 :: xs') s
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.monoid_reflect
val monoid_reflect: #a: Type -> m: cm a -> am: amap a -> e1: exp -> e2: exp -> squash (xsdenote m am (canon e1) == xsdenote m am (canon e2)) -> squash (mdenote m am e1 == mdenote m am e2)
val monoid_reflect: #a: Type -> m: cm a -> am: amap a -> e1: exp -> e2: exp -> squash (xsdenote m am (canon e1) == xsdenote m am (canon e2)) -> squash (mdenote m am e1 == mdenote m am e2)
let monoid_reflect (#a:Type) (m:cm a) (am:amap a) (e1 e2:exp) (_ : squash (xsdenote m am (canon e1) == xsdenote m am (canon e2))) : squash (mdenote m am e1 == mdenote m am e2) = canon_correct m am e1; canon_correct m am e2
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 46, "end_line": 209, "start_col": 0, "start_line": 206 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s let rec apply_swaps_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (ss:list (swap (length xs))): Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) = match ss with | [] -> () | s::ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss' let permute_via_swaps (p:permute) = (#a:Type) -> (am:amap a) -> xs:list atom -> Lemma (exists ss. p xs == apply_swaps xs ss) let permute_via_swaps_correct_aux (p:permute) (pvs:permute_via_swaps p) (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (p xs)) = pvs am xs; assert(exists ss. p xs == apply_swaps xs ss); exists_elim (xsdenote m am xs == xsdenote m am (p xs)) (() <: squash (exists ss. p xs == apply_swaps xs ss)) (fun ss -> apply_swaps_correct m am xs ss) let permute_via_swaps_correct (p:permute) (pvs:permute_via_swaps p) : permute_correct p = fun #a -> permute_via_swaps_correct_aux p pvs #a (***** Sorting atoms is a correct permutation (since it can be done by swaps) *) // Here we sort the variable numbers let sort : permute = List.Tot.Base.sortWith #nat (compare_of_bool (<)) let sort_via_swaps (#a:Type) (am : amap a) (xs:list atom) : Lemma (exists ss. sort xs == apply_swaps xs ss) = List.Tot.Properties.sortWith_permutation #nat (compare_of_bool (<)) xs; let ss = equal_counts_implies_swaps #nat xs (sort xs) in () let sort_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (sort xs)) = permute_via_swaps_correct sort (fun #a am -> sort_via_swaps am) m am xs let sort_correct : permute_correct sort = (fun #a -> sort_correct_aux #a) (***** Canonicalization tactics *) (* [@@plugin] *) let canon (e:exp) = sort (flatten e) let canon_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (canon e)) = flatten_correct m am e; sort_correct m am (flatten e) let monoid_reflect_orig (#a:Type) (m:cm a) (am:amap a) (e1 e2:exp) : Lemma (requires (xsdenote m am (canon e1) == xsdenote m am (canon e2))) (ensures (mdenote m am e1 == mdenote m am e2)) = canon_correct m am e1; canon_correct m am e2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.Algebra.CommMonoid.cm a -> am: FStar.Tactics.CanonCommMonoidSimple.amap a -> e1: FStar.Tactics.CanonCommMonoidSimple.exp -> e2: FStar.Tactics.CanonCommMonoidSimple.exp -> _: Prims.squash (FStar.Tactics.CanonCommMonoidSimple.xsdenote m am (FStar.Tactics.CanonCommMonoidSimple.canon e1) == FStar.Tactics.CanonCommMonoidSimple.xsdenote m am (FStar.Tactics.CanonCommMonoidSimple.canon e2)) -> Prims.squash (FStar.Tactics.CanonCommMonoidSimple.mdenote m am e1 == FStar.Tactics.CanonCommMonoidSimple.mdenote m am e2)
Prims.Tot
[ "total" ]
[]
[ "FStar.Algebra.CommMonoid.cm", "FStar.Tactics.CanonCommMonoidSimple.amap", "FStar.Tactics.CanonCommMonoidSimple.exp", "Prims.squash", "Prims.eq2", "FStar.Tactics.CanonCommMonoidSimple.xsdenote", "FStar.Tactics.CanonCommMonoidSimple.canon", "FStar.Tactics.CanonCommMonoidSimple.canon_correct", "Prims.unit", "FStar.Tactics.CanonCommMonoidSimple.mdenote" ]
[]
false
false
true
false
false
let monoid_reflect (#a: Type) (m: cm a) (am: amap a) (e1: exp) (e2: exp) (_: squash (xsdenote m am (canon e1) == xsdenote m am (canon e2))) : squash (mdenote m am e1 == mdenote m am e2) =
canon_correct m am e1; canon_correct m am e2
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.canon_correct
val canon_correct (#a: Type) (m: cm a) (am: amap a) (e: exp) : Lemma (mdenote m am e == xsdenote m am (canon e))
val canon_correct (#a: Type) (m: cm a) (am: amap a) (e: exp) : Lemma (mdenote m am e == xsdenote m am (canon e))
let canon_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (canon e)) = flatten_correct m am e; sort_correct m am (flatten e)
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 55, "end_line": 199, "start_col": 0, "start_line": 197 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s let rec apply_swaps_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (ss:list (swap (length xs))): Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) = match ss with | [] -> () | s::ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss' let permute_via_swaps (p:permute) = (#a:Type) -> (am:amap a) -> xs:list atom -> Lemma (exists ss. p xs == apply_swaps xs ss) let permute_via_swaps_correct_aux (p:permute) (pvs:permute_via_swaps p) (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (p xs)) = pvs am xs; assert(exists ss. p xs == apply_swaps xs ss); exists_elim (xsdenote m am xs == xsdenote m am (p xs)) (() <: squash (exists ss. p xs == apply_swaps xs ss)) (fun ss -> apply_swaps_correct m am xs ss) let permute_via_swaps_correct (p:permute) (pvs:permute_via_swaps p) : permute_correct p = fun #a -> permute_via_swaps_correct_aux p pvs #a (***** Sorting atoms is a correct permutation (since it can be done by swaps) *) // Here we sort the variable numbers let sort : permute = List.Tot.Base.sortWith #nat (compare_of_bool (<)) let sort_via_swaps (#a:Type) (am : amap a) (xs:list atom) : Lemma (exists ss. sort xs == apply_swaps xs ss) = List.Tot.Properties.sortWith_permutation #nat (compare_of_bool (<)) xs; let ss = equal_counts_implies_swaps #nat xs (sort xs) in () let sort_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (sort xs)) = permute_via_swaps_correct sort (fun #a am -> sort_via_swaps am) m am xs let sort_correct : permute_correct sort = (fun #a -> sort_correct_aux #a) (***** Canonicalization tactics *) (* [@@plugin] *) let canon (e:exp) = sort (flatten e)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.Algebra.CommMonoid.cm a -> am: FStar.Tactics.CanonCommMonoidSimple.amap a -> e: FStar.Tactics.CanonCommMonoidSimple.exp -> FStar.Pervasives.Lemma (ensures FStar.Tactics.CanonCommMonoidSimple.mdenote m am e == FStar.Tactics.CanonCommMonoidSimple.xsdenote m am (FStar.Tactics.CanonCommMonoidSimple.canon e))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Algebra.CommMonoid.cm", "FStar.Tactics.CanonCommMonoidSimple.amap", "FStar.Tactics.CanonCommMonoidSimple.exp", "FStar.Tactics.CanonCommMonoidSimple.sort_correct", "FStar.Tactics.CanonCommMonoidSimple.flatten", "Prims.unit", "FStar.Tactics.CanonCommMonoidSimple.flatten_correct", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Tactics.CanonCommMonoidSimple.mdenote", "FStar.Tactics.CanonCommMonoidSimple.xsdenote", "FStar.Tactics.CanonCommMonoidSimple.canon", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let canon_correct (#a: Type) (m: cm a) (am: amap a) (e: exp) : Lemma (mdenote m am e == xsdenote m am (canon e)) =
flatten_correct m am e; sort_correct m am (flatten e)
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.monoid_reflect_orig
val monoid_reflect_orig (#a: Type) (m: cm a) (am: amap a) (e1 e2: exp) : Lemma (requires (xsdenote m am (canon e1) == xsdenote m am (canon e2))) (ensures (mdenote m am e1 == mdenote m am e2))
val monoid_reflect_orig (#a: Type) (m: cm a) (am: amap a) (e1 e2: exp) : Lemma (requires (xsdenote m am (canon e1) == xsdenote m am (canon e2))) (ensures (mdenote m am e1 == mdenote m am e2))
let monoid_reflect_orig (#a:Type) (m:cm a) (am:amap a) (e1 e2:exp) : Lemma (requires (xsdenote m am (canon e1) == xsdenote m am (canon e2))) (ensures (mdenote m am e1 == mdenote m am e2)) = canon_correct m am e1; canon_correct m am e2
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 46, "end_line": 204, "start_col": 0, "start_line": 201 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s let rec apply_swaps_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (ss:list (swap (length xs))): Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) = match ss with | [] -> () | s::ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss' let permute_via_swaps (p:permute) = (#a:Type) -> (am:amap a) -> xs:list atom -> Lemma (exists ss. p xs == apply_swaps xs ss) let permute_via_swaps_correct_aux (p:permute) (pvs:permute_via_swaps p) (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (p xs)) = pvs am xs; assert(exists ss. p xs == apply_swaps xs ss); exists_elim (xsdenote m am xs == xsdenote m am (p xs)) (() <: squash (exists ss. p xs == apply_swaps xs ss)) (fun ss -> apply_swaps_correct m am xs ss) let permute_via_swaps_correct (p:permute) (pvs:permute_via_swaps p) : permute_correct p = fun #a -> permute_via_swaps_correct_aux p pvs #a (***** Sorting atoms is a correct permutation (since it can be done by swaps) *) // Here we sort the variable numbers let sort : permute = List.Tot.Base.sortWith #nat (compare_of_bool (<)) let sort_via_swaps (#a:Type) (am : amap a) (xs:list atom) : Lemma (exists ss. sort xs == apply_swaps xs ss) = List.Tot.Properties.sortWith_permutation #nat (compare_of_bool (<)) xs; let ss = equal_counts_implies_swaps #nat xs (sort xs) in () let sort_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (sort xs)) = permute_via_swaps_correct sort (fun #a am -> sort_via_swaps am) m am xs let sort_correct : permute_correct sort = (fun #a -> sort_correct_aux #a) (***** Canonicalization tactics *) (* [@@plugin] *) let canon (e:exp) = sort (flatten e) let canon_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (canon e)) = flatten_correct m am e; sort_correct m am (flatten e)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.Algebra.CommMonoid.cm a -> am: FStar.Tactics.CanonCommMonoidSimple.amap a -> e1: FStar.Tactics.CanonCommMonoidSimple.exp -> e2: FStar.Tactics.CanonCommMonoidSimple.exp -> FStar.Pervasives.Lemma (requires FStar.Tactics.CanonCommMonoidSimple.xsdenote m am (FStar.Tactics.CanonCommMonoidSimple.canon e1) == FStar.Tactics.CanonCommMonoidSimple.xsdenote m am (FStar.Tactics.CanonCommMonoidSimple.canon e2)) (ensures FStar.Tactics.CanonCommMonoidSimple.mdenote m am e1 == FStar.Tactics.CanonCommMonoidSimple.mdenote m am e2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Algebra.CommMonoid.cm", "FStar.Tactics.CanonCommMonoidSimple.amap", "FStar.Tactics.CanonCommMonoidSimple.exp", "FStar.Tactics.CanonCommMonoidSimple.canon_correct", "Prims.unit", "Prims.eq2", "FStar.Tactics.CanonCommMonoidSimple.xsdenote", "FStar.Tactics.CanonCommMonoidSimple.canon", "Prims.squash", "FStar.Tactics.CanonCommMonoidSimple.mdenote", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let monoid_reflect_orig (#a: Type) (m: cm a) (am: amap a) (e1 e2: exp) : Lemma (requires (xsdenote m am (canon e1) == xsdenote m am (canon e2))) (ensures (mdenote m am e1 == mdenote m am e2)) =
canon_correct m am e1; canon_correct m am e2
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.reification_aux
val reification_aux (#a: Type) (ts: list term) (am: amap a) (mult unit t: term) : Tac (exp * list term * amap a)
val reification_aux (#a: Type) (ts: list term) (am: amap a) (mult unit t: term) : Tac (exp * list term * amap a)
let rec reification_aux (#a:Type) (ts:list term) (am:amap a) (mult unit t : term) : Tac (exp * list term * amap a) = let hd, tl = collect_app_ref t in let fatom (t:term) (ts:list term) (am:amap a) : Tac (exp * list term * amap a) = match where t ts with | Some v -> (Atom v, ts, am) | None -> let vfresh = length ts in let z = unquote t in (Atom vfresh, ts @ [t], update vfresh z am) in match inspect hd, list_unref tl with | Tv_FVar fv, [(t1, Q_Explicit) ; (t2, Q_Explicit)] -> if term_eq (pack (Tv_FVar fv)) mult then (let (e1,ts,am) = reification_aux ts am mult unit t1 in let (e2,ts,am) = reification_aux ts am mult unit t2 in (Mult e1 e2, ts, am)) else fatom t ts am | _, _ -> if term_eq t unit then (Unit, ts, am) else fatom t ts am
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 22, "end_line": 240, "start_col": 0, "start_line": 221 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s let rec apply_swaps_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (ss:list (swap (length xs))): Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) = match ss with | [] -> () | s::ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss' let permute_via_swaps (p:permute) = (#a:Type) -> (am:amap a) -> xs:list atom -> Lemma (exists ss. p xs == apply_swaps xs ss) let permute_via_swaps_correct_aux (p:permute) (pvs:permute_via_swaps p) (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (p xs)) = pvs am xs; assert(exists ss. p xs == apply_swaps xs ss); exists_elim (xsdenote m am xs == xsdenote m am (p xs)) (() <: squash (exists ss. p xs == apply_swaps xs ss)) (fun ss -> apply_swaps_correct m am xs ss) let permute_via_swaps_correct (p:permute) (pvs:permute_via_swaps p) : permute_correct p = fun #a -> permute_via_swaps_correct_aux p pvs #a (***** Sorting atoms is a correct permutation (since it can be done by swaps) *) // Here we sort the variable numbers let sort : permute = List.Tot.Base.sortWith #nat (compare_of_bool (<)) let sort_via_swaps (#a:Type) (am : amap a) (xs:list atom) : Lemma (exists ss. sort xs == apply_swaps xs ss) = List.Tot.Properties.sortWith_permutation #nat (compare_of_bool (<)) xs; let ss = equal_counts_implies_swaps #nat xs (sort xs) in () let sort_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (sort xs)) = permute_via_swaps_correct sort (fun #a am -> sort_via_swaps am) m am xs let sort_correct : permute_correct sort = (fun #a -> sort_correct_aux #a) (***** Canonicalization tactics *) (* [@@plugin] *) let canon (e:exp) = sort (flatten e) let canon_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (canon e)) = flatten_correct m am e; sort_correct m am (flatten e) let monoid_reflect_orig (#a:Type) (m:cm a) (am:amap a) (e1 e2:exp) : Lemma (requires (xsdenote m am (canon e1) == xsdenote m am (canon e2))) (ensures (mdenote m am e1 == mdenote m am e2)) = canon_correct m am e1; canon_correct m am e2 let monoid_reflect (#a:Type) (m:cm a) (am:amap a) (e1 e2:exp) (_ : squash (xsdenote m am (canon e1) == xsdenote m am (canon e2))) : squash (mdenote m am e1 == mdenote m am e2) = canon_correct m am e1; canon_correct m am e2 (* Finds the position of first occurrence of x in xs. This is now specialized to terms and their funny term_eq. *) let rec where_aux (n:nat) (x:term) (xs:list term) : Tac (option nat) = match xs with | [] -> None | x'::xs' -> if term_eq x x' then Some n else where_aux (n+1) x xs' let where = where_aux 0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ts: Prims.list FStar.Tactics.NamedView.term -> am: FStar.Tactics.CanonCommMonoidSimple.amap a -> mult: FStar.Tactics.NamedView.term -> unit: FStar.Tactics.NamedView.term -> t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac ((FStar.Tactics.CanonCommMonoidSimple.exp * Prims.list FStar.Tactics.NamedView.term) * FStar.Tactics.CanonCommMonoidSimple.amap a)
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.list", "FStar.Tactics.NamedView.term", "FStar.Tactics.CanonCommMonoidSimple.amap", "FStar.Stubs.Reflection.Types.term", "Prims.l_or", "Prims.eq2", "Prims.precedes", "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Pervasives.Native.fst", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.Types.fv", "FStar.Tactics.CanonCommMonoidSimple.exp", "FStar.Pervasives.Native.Mktuple3", "FStar.Tactics.CanonCommMonoidSimple.Mult", "FStar.Pervasives.Native.tuple3", "FStar.Tactics.CanonCommMonoidSimple.reification_aux", "Prims.bool", "FStar.Tactics.CanonCommMonoidSimple.term_eq", "FStar.Tactics.NamedView.pack", "FStar.Tactics.NamedView.Tv_FVar", "FStar.Tactics.NamedView.named_term_view", "FStar.Pervasives.Native.tuple2", "FStar.Tactics.CanonCommMonoidSimple.Unit", "FStar.Pervasives.Native.Mktuple2", "FStar.List.Tot.Base.list_unref", "FStar.Tactics.NamedView.inspect", "Prims.nat", "FStar.Tactics.CanonCommMonoidSimple.Atom", "FStar.List.Tot.Base.op_At", "Prims.Cons", "Prims.Nil", "FStar.Tactics.CanonCommMonoidSimple.update", "FStar.Stubs.Tactics.V2.Builtins.unquote", "FStar.List.Tot.Base.length", "FStar.Pervasives.Native.option", "FStar.Tactics.CanonCommMonoidSimple.where", "FStar.Reflection.V2.Derived.Lemmas.collect_app_ref" ]
[ "recursion" ]
false
true
false
false
false
let rec reification_aux (#a: Type) (ts: list term) (am: amap a) (mult unit t: term) : Tac (exp * list term * amap a) =
let hd, tl = collect_app_ref t in let fatom (t: term) (ts: list term) (am: amap a) : Tac ((exp * list term) * amap a) = match where t ts with | Some v -> (Atom v, ts, am) | None -> let vfresh = length ts in let z = unquote t in (Atom vfresh, ts @ [t], update vfresh z am) in match inspect hd, list_unref tl with | Tv_FVar fv, [t1, Q_Explicit ; t2, Q_Explicit] -> if term_eq (pack (Tv_FVar fv)) mult then (let e1, ts, am = reification_aux ts am mult unit t1 in let e2, ts, am = reification_aux ts am mult unit t2 in (Mult e1 e2, ts, am)) else fatom t ts am | _, _ -> if term_eq t unit then (Unit, ts, am) else fatom t ts am
false
FStar.Tactics.CanonCommMonoidSimple.fst
FStar.Tactics.CanonCommMonoidSimple.where_aux
val where_aux (n: nat) (x: term) (xs: list term) : Tac (option nat)
val where_aux (n: nat) (x: term) (xs: list term) : Tac (option nat)
let rec where_aux (n:nat) (x:term) (xs:list term) : Tac (option nat) = match xs with | [] -> None | x'::xs' -> if term_eq x x' then Some n else where_aux (n+1) x xs'
{ "file_name": "ulib/FStar.Tactics.CanonCommMonoidSimple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 69, "end_line": 217, "start_col": 0, "start_line": 213 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.CanonCommMonoidSimple open FStar.Algebra.CommMonoid open FStar.List open FStar.Reflection.V2 open FStar.Tactics.V2 open FStar.Classical open FStar.Tactics.CanonCommSwaps let term_eq = FStar.Tactics.term_eq_old (* A simple expression canonizer for commutative monoids. For a canonizer with more features see FStar.Tactics.CanonCommMonoid.fst. Inspired by: - http://adam.chlipala.net/cpdt/html/Cpdt.Reflection.html - http://poleiro.info/posts/2015-04-13-writing-reflective-tactics.html *) (* Only dump when debugging is on *) let dump m = if debugging () then dump m (***** Expression syntax *) let atom : eqtype = nat type exp : Type = | Unit : exp | Mult : exp -> exp -> exp | Atom : atom -> exp let rec exp_to_string (e:exp) : string = match e with | Unit -> "Unit" | Atom x -> "Atom " ^ string_of_int (x <: atom) | Mult e1 e2 -> "Mult (" ^ exp_to_string e1 ^ ") (" ^ exp_to_string e2 ^ ")" (***** Expression denotation *) // Use a map that stores for each atom // (1) its denotation that should be treated abstractly (type a) and // (2) user-specified extra information depending on its term (type b) let amap (a:Type) = list (atom * a) * a let const (#a:Type) (xa:a) : amap a = ([], xa) let select (#a:Type) (x:atom) (am:amap a) : Tot a = match assoc #atom #a x (fst am) with | Some a -> a | _ -> snd am let update (#a:Type) (x:atom) (xa:a) (am:amap a) : amap a = (x, xa)::fst am, snd am let rec mdenote (#a:Type) (m:cm a) (am:amap a) (e:exp) : a = match e with | Unit -> CM?.unit m | Atom x -> select x am | Mult e1 e2 -> CM?.mult m (mdenote m am e1) (mdenote m am e2) let rec xsdenote (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : a = match xs with | [] -> CM?.unit m | [x] -> select x am | x::xs' -> CM?.mult m (select x am) (xsdenote m am xs') (***** Flattening expressions to lists of atoms *) let rec flatten (e:exp) : list atom = match e with | Unit -> [] | Atom x -> [x] | Mult e1 e2 -> flatten e1 @ flatten e2 let rec flatten_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs1 xs2:list atom) : Lemma (xsdenote m am (xs1 @ xs2) == CM?.mult m (xsdenote m am xs1) (xsdenote m am xs2)) = match xs1 with | [] -> CM?.identity m (xsdenote m am xs2) | [x] -> if (Nil? xs2) then right_identity m (select x am) | x::xs1' -> (CM?.associativity m (select x am) (xsdenote m am xs1') (xsdenote m am xs2); flatten_correct_aux m am xs1' xs2) let rec flatten_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (flatten e)) = match e with | Unit | Atom _ -> () | Mult e1 e2 -> flatten_correct_aux m am (flatten e1) (flatten e2); flatten_correct m am e1; flatten_correct m am e2 (***** Permuting the lists of atoms by swapping adjacent elements *) let permute = list atom -> list atom // high-level correctness criterion for permutations let permute_correct (p:permute) = #a:Type -> m:cm a -> am:amap a -> xs:list atom -> Lemma (xsdenote m am xs == xsdenote m am (p xs)) // sufficient condition: // permutation has to be expressible as swaps of adjacent list elements // In the general case, an arbitrary permutation can be done via swaps. // (see FStar.Tactics.CanonCommSwaps for a proof) let rec apply_swap_aux_correct (#a:Type) (n:nat) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs + n)) : Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swap_aux n xs s))) (decreases xs) = match xs with | [] | [_] -> () | x1 :: x2 :: xs' -> if n = (s <: nat) then (// x1 + (x2 + xs') =a (x1 + x2) + xs' // =c (x2 + x1) + xs' = a x2 + (x1 + xs') let a = CM?.associativity m in a (select x1 am) (select x2 am) (xsdenote m am xs'); a (select x2 am) (select x1 am) (xsdenote m am xs'); CM?.commutativity m (select x1 am) (select x2 am)) else apply_swap_aux_correct (n+1) m am (x2 :: xs') s let apply_swap_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (s:swap (length xs)): Lemma (ensures (xsdenote m am xs == xsdenote m am (apply_swap xs s))) (decreases xs) = apply_swap_aux_correct 0 m am xs s let rec apply_swaps_correct (#a:Type) (m:cm a) (am:amap a) (xs:list atom) (ss:list (swap (length xs))): Lemma (requires True) (ensures (xsdenote m am xs == xsdenote m am (apply_swaps xs ss))) (decreases ss) = match ss with | [] -> () | s::ss' -> apply_swap_correct m am xs s; apply_swaps_correct m am (apply_swap xs s) ss' let permute_via_swaps (p:permute) = (#a:Type) -> (am:amap a) -> xs:list atom -> Lemma (exists ss. p xs == apply_swaps xs ss) let permute_via_swaps_correct_aux (p:permute) (pvs:permute_via_swaps p) (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (p xs)) = pvs am xs; assert(exists ss. p xs == apply_swaps xs ss); exists_elim (xsdenote m am xs == xsdenote m am (p xs)) (() <: squash (exists ss. p xs == apply_swaps xs ss)) (fun ss -> apply_swaps_correct m am xs ss) let permute_via_swaps_correct (p:permute) (pvs:permute_via_swaps p) : permute_correct p = fun #a -> permute_via_swaps_correct_aux p pvs #a (***** Sorting atoms is a correct permutation (since it can be done by swaps) *) // Here we sort the variable numbers let sort : permute = List.Tot.Base.sortWith #nat (compare_of_bool (<)) let sort_via_swaps (#a:Type) (am : amap a) (xs:list atom) : Lemma (exists ss. sort xs == apply_swaps xs ss) = List.Tot.Properties.sortWith_permutation #nat (compare_of_bool (<)) xs; let ss = equal_counts_implies_swaps #nat xs (sort xs) in () let sort_correct_aux (#a:Type) (m:cm a) (am:amap a) (xs:list atom) : Lemma (xsdenote m am xs == xsdenote m am (sort xs)) = permute_via_swaps_correct sort (fun #a am -> sort_via_swaps am) m am xs let sort_correct : permute_correct sort = (fun #a -> sort_correct_aux #a) (***** Canonicalization tactics *) (* [@@plugin] *) let canon (e:exp) = sort (flatten e) let canon_correct (#a:Type) (m:cm a) (am:amap a) (e:exp) : Lemma (mdenote m am e == xsdenote m am (canon e)) = flatten_correct m am e; sort_correct m am (flatten e) let monoid_reflect_orig (#a:Type) (m:cm a) (am:amap a) (e1 e2:exp) : Lemma (requires (xsdenote m am (canon e1) == xsdenote m am (canon e2))) (ensures (mdenote m am e1 == mdenote m am e2)) = canon_correct m am e1; canon_correct m am e2 let monoid_reflect (#a:Type) (m:cm a) (am:amap a) (e1 e2:exp) (_ : squash (xsdenote m am (canon e1) == xsdenote m am (canon e2))) : squash (mdenote m am e1 == mdenote m am e2) = canon_correct m am e1; canon_correct m am e2 (* Finds the position of first occurrence of x in xs.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.CanonCommSwaps.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.CanonCommMonoidSimple.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSwaps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> x: FStar.Tactics.NamedView.term -> xs: Prims.list FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option Prims.nat)
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.nat", "FStar.Tactics.NamedView.term", "Prims.list", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Some", "Prims.bool", "FStar.Tactics.CanonCommMonoidSimple.where_aux", "Prims.op_Addition", "FStar.Tactics.CanonCommMonoidSimple.term_eq" ]
[ "recursion" ]
false
true
false
false
false
let rec where_aux (n: nat) (x: term) (xs: list term) : Tac (option nat) =
match xs with | [] -> None | x' :: xs' -> if term_eq x x' then Some n else where_aux (n + 1) x xs'
false
Steel.ST.Array.fst
Steel.ST.Array.init_compare_inv
val init_compare_inv (#o: _) (#t: eqtype) (#p0 #p1: perm) (a0 a1: array t) (#s0 #s1: Seq.seq t) (l: US.t) (ctr: R.ref (option US.t)) : STGhost unit o (let open US in ((pts_to a0 p0 s0) `star` (pts_to a1 p1 s1)) `star` (R.pts_to ctr Steel.FractionalPermission.full_perm (Some 0sz))) (fun _ -> exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr)) (requires (length a0 > 0 /\ length a0 == length a1 /\ US.v l == length a0)) (ensures (fun _ -> True))
val init_compare_inv (#o: _) (#t: eqtype) (#p0 #p1: perm) (a0 a1: array t) (#s0 #s1: Seq.seq t) (l: US.t) (ctr: R.ref (option US.t)) : STGhost unit o (let open US in ((pts_to a0 p0 s0) `star` (pts_to a1 p1 s1)) `star` (R.pts_to ctr Steel.FractionalPermission.full_perm (Some 0sz))) (fun _ -> exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr)) (requires (length a0 > 0 /\ length a0 == length a1 /\ US.v l == length a0)) (ensures (fun _ -> True))
let init_compare_inv #o (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (#s0: Seq.seq t) (#s1: Seq.seq t) (l:US.t) (ctr : R.ref (option US.t)) : STGhost unit o (let open US in pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` R.pts_to ctr Steel.FractionalPermission.full_perm (Some 0sz)) (fun _ -> exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr)) (requires ( length a0 > 0 /\ length a0 == length a1 /\ US.v l == length a0 )) (ensures (fun _ -> True)) = pts_to_length a0 _; pts_to_length a1 _; intro_pure (equal_up_to s0 s1 (Ghost.hide (Some 0sz))); rewrite (R.pts_to ctr Steel.FractionalPermission.full_perm (Some 0sz)) (R.pts_to ctr Steel.FractionalPermission.full_perm (Ghost.hide (Some 0sz))); intro_exists_compare_inv a0 a1 l ctr (Ghost.hide (Some 0sz))
{ "file_name": "lib/steel/Steel.ST.Array.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 66, "end_line": 442, "start_col": 0, "start_line": 416 }
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array module US = FStar.SizeT /// Lifting a value of universe 0 to universe 1. We use /// FStar.Universe, since FStar.Extraction.Krml is set to extract /// those functions to identity. inline_for_extraction [@@ noextract_to "krml"] let raise_t (t: Type0) : Type u#1 = FStar.Universe.raise_t t inline_for_extraction [@@noextract_to "krml"] let raise (#t: Type) (x: t) : Tot (raise_t t) = FStar.Universe.raise_val x inline_for_extraction [@@noextract_to "krml"] let lower (#t: Type) (x: raise_t t) : Tot t = FStar.Universe.downgrade_val x /// A map operation on sequences. Here we only need Ghost versions, /// because such sequences are only used in vprops or with their /// selectors. let rec seq_map (#t: Type u#a) (#t' : Type u#b) (f: (t -> GTot t')) (s: Seq.seq t) : Ghost (Seq.seq t') (requires True) (ensures (fun s' -> Seq.length s' == Seq.length s /\ (forall i . {:pattern (Seq.index s' i)} Seq.index s' i == f (Seq.index s i)) )) (decreases (Seq.length s)) = if Seq.length s = 0 then Seq.empty else Seq.cons (f (Seq.index s 0)) (seq_map f (Seq.slice s 1 (Seq.length s))) let seq_map_append (#t: Type u#a) (#t': Type u#b) (f: (t -> GTot t')) (s1 s2: Seq.seq t) : Lemma (seq_map f (s1 `Seq.append` s2) `Seq.equal` (seq_map f s1 `Seq.append` seq_map f s2)) = () let seq_map_raise_inj (#elt: Type0) (s1 s2: Seq.seq elt) : Lemma (requires (seq_map raise s1 == seq_map raise s2)) (ensures (s1 == s2)) [SMTPat (seq_map raise s1); SMTPat (seq_map raise s2)] = assert (seq_map lower (seq_map raise s1) `Seq.equal` s1); assert (seq_map lower (seq_map raise s2) `Seq.equal` s2) /// Implementation of the interface /// base, ptr, array, pts_to module H = Steel.ST.HigherArray let base_t elt = H.base_t (raise_t elt) let base_len b = H.base_len b let ptr elt = H.ptr (raise_t elt) let null_ptr elt = H.null_ptr (raise_t elt) let is_null_ptr p = H.is_null_ptr p let base p = H.base p let offset p = H.offset p let ptr_base_offset_inj p1 p2 = H.ptr_base_offset_inj p1 p2 let base_len_null_ptr elt = H.base_len_null_ptr (raise_t elt) let length_fits a = H.length_fits a let pts_to a p s = H.pts_to a p (seq_map raise s) let pts_to_length a s = H.pts_to_length a _ let h_array_eq' (#t: Type u#1) (a1 a2: H.array t) : Lemma (requires ( dfst a1 == dfst a2 /\ (Ghost.reveal (dsnd a1) <: nat) == Ghost.reveal (dsnd a2) )) (ensures ( a1 == a2 )) = () let pts_to_not_null #_ #t #p a s = let _ = H.pts_to_not_null #_ #_ #p a (seq_map raise s) in assert (a =!= H.null #(raise_t t)); Classical.move_requires (h_array_eq' a) (H.null #(raise_t t)); noop () let pts_to_inj a p1 s1 p2 s2 = H.pts_to_inj a p1 (seq_map raise s1) p2 (seq_map raise s2) /// Non-selector operations. let malloc x n = let res = H.malloc (raise x) n in assert (seq_map raise (Seq.create (US.v n) x) `Seq.equal` Seq.create (US.v n) (raise x)); rewrite (H.pts_to res _ _) (pts_to res _ _); return res let free #_ x = let s = elim_exists () in rewrite (pts_to x _ _) (H.pts_to x P.full_perm (seq_map raise s)); H.free x let share #_ #_ #x a p p1 p2 = rewrite (pts_to a _ _) (H.pts_to a p (seq_map raise x)); H.share a p p1 p2; rewrite (H.pts_to a p1 _) (pts_to a p1 x); rewrite (H.pts_to a p2 _) (pts_to a p2 x) let gather #_ #_ a #x1 p1 #x2 p2 = rewrite (pts_to a p1 _) (H.pts_to a p1 (seq_map raise x1)); rewrite (pts_to a p2 _) (H.pts_to a p2 (seq_map raise x2)); H.gather a p1 p2; rewrite (H.pts_to a _ _) (pts_to _ _ _) let index #_ #p a #s i = rewrite (pts_to a _ _) (H.pts_to a p (seq_map raise s)); let res = H.index a i in rewrite (H.pts_to _ _ _) (pts_to _ _ _); return (lower res) let upd #_ a #s i v = rewrite (pts_to a _ _) (H.pts_to a P.full_perm (seq_map raise s)); H.upd a i (raise v); assert (seq_map raise (Seq.upd s (US.v i) v) `Seq.equal` Seq.upd (seq_map raise s) (US.v i) (raise v)); rewrite (H.pts_to _ _ _) (pts_to _ _ _) let ghost_join #_ #_ #x1 #x2 #p a1 a2 h = rewrite (pts_to a1 _ _) (H.pts_to a1 p (seq_map raise x1)); rewrite (pts_to a2 _ _) (H.pts_to a2 p (seq_map raise x2)); H.ghost_join a1 a2 h; assert (seq_map raise (x1 `Seq.append` x2) `Seq.equal` (seq_map raise x1 `Seq.append` seq_map raise x2)); rewrite (H.pts_to _ _ _) (H.pts_to (merge a1 a2) p (seq_map raise (x1 `Seq.append` x2))); rewrite (H.pts_to _ _ _) (pts_to (merge a1 a2) _ _) let ptr_shift p off = H.ptr_shift p off let ghost_split #_ #_ #x #p a i = rewrite (pts_to a _ _) (H.pts_to a p (seq_map raise x)); let _ = H.ghost_split a i in //H.ghost_split a i; assert (seq_map raise (Seq.slice x 0 (US.v i)) `Seq.equal` Seq.slice (seq_map raise x) 0 (US.v i)); rewrite (H.pts_to (H.split_l a i) _ _) (H.pts_to (split_l a i) p (seq_map raise (Seq.slice x 0 (US.v i)))); rewrite (H.pts_to (split_l a i) _ _) (pts_to (split_l a i) _ _); assert (seq_map raise (Seq.slice x (US.v i) (Seq.length x)) `Seq.equal` Seq.slice (seq_map raise x) (US.v i) (Seq.length (seq_map raise x))); Seq.lemma_split x (US.v i); rewrite (H.pts_to (H.split_r a i) _ _) (H.pts_to (split_r a i) p (seq_map raise (Seq.slice x (US.v i) (Seq.length x)))); rewrite (H.pts_to (split_r a i) _ _) (pts_to (split_r a i) _ _) let memcpy a0 a1 l = H.memcpy a0 a1 l //////////////////////////////////////////////////////////////////////////////// // compare //////////////////////////////////////////////////////////////////////////////// module R = Steel.ST.Reference #push-options "--fuel 0 --ifuel 1 --z3rlimit_factor 2" let equal_up_to #t (s0: Seq.seq t) (s1: Seq.seq t) (v : option US.t) : prop = Seq.length s0 = Seq.length s1 /\ (match v with | None -> Ghost.reveal s0 =!= Ghost.reveal s1 | Some v -> US.v v <= Seq.length s0 /\ Seq.slice s0 0 (US.v v) `Seq.equal` Seq.slice s1 0 (US.v v)) let within_bounds (x:option US.t) (l:US.t) (b:Ghost.erased bool) : prop = if b then Some? x /\ US.(Some?.v x <^ l) else None? x \/ US.(Some?.v x >=^ l) let compare_inv (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (s0: Seq.seq t) (s1: Seq.seq t) (l:US.t) (ctr : R.ref (option US.t)) (b: bool) = pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` exists_ (fun (x:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm x `star` pure (equal_up_to s0 s1 x) `star` pure (within_bounds x l b)) let elim_compare_inv #o (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (#s0: Seq.seq t) (#s1: Seq.seq t) (l:US.t) (ctr : R.ref (option US.t)) (b: bool) : STGhostT (Ghost.erased (option US.t)) o (compare_inv a0 a1 s0 s1 l ctr b) (fun x -> let open US in pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` R.pts_to ctr Steel.FractionalPermission.full_perm x `star` pure (equal_up_to s0 s1 x) `star` pure (within_bounds x l b)) = let open US in assert_spinoff ((compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr b) == (pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` exists_ (fun (v:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm v `star` pure (equal_up_to s0 s1 v) `star` pure (within_bounds v l b)))); rewrite (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr b) (pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` exists_ (fun (v:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm v `star` pure (equal_up_to s0 s1 v) `star` pure (within_bounds v l b))); let _v = elim_exists () in _v let intro_compare_inv #o (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (#s0: Seq.seq t) (#s1: Seq.seq t) (l:US.t) (ctr : R.ref (option US.t)) (x: Ghost.erased (option US.t)) (b:bool { within_bounds x l b }) : STGhostT unit o (let open US in pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` R.pts_to ctr Steel.FractionalPermission.full_perm x `star` pure (equal_up_to s0 s1 x)) (fun _ -> compare_inv a0 a1 s0 s1 l ctr (Ghost.hide b)) = let open US in intro_pure (within_bounds x l (Ghost.hide b)); intro_exists_erased x (fun (x:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm x `star` pure (equal_up_to s0 s1 x) `star` pure (within_bounds x l (Ghost.hide b))); assert_norm ((compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr (Ghost.hide b)) == (pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` exists_ (fun (v:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm v `star` pure (equal_up_to s0 s1 v) `star` pure (within_bounds v l (Ghost.hide b))))); rewrite (pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` exists_ (fun (v:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm v `star` pure (equal_up_to s0 s1 v) `star` pure (within_bounds v l (Ghost.hide b)))) (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr (Ghost.hide b)) let intro_exists_compare_inv #o (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (#s0: Seq.seq t) (#s1: Seq.seq t) (l:US.t) (ctr : R.ref (option US.t)) (x: Ghost.erased (option US.t)) : STGhostT unit o (let open US in pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` R.pts_to ctr Steel.FractionalPermission.full_perm x `star` pure (equal_up_to s0 s1 x)) (fun _ -> exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr)) = let b : bool = match Ghost.reveal x with | None -> false | Some x -> US.(x <^ l) in assert (within_bounds x l b); intro_compare_inv #_ #_ #p0 #p1 a0 a1 #s0 #s1 l ctr x b; intro_exists _ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr) let extend_equal_up_to_lemma (#t:Type0) (s0:Seq.seq t) (s1:Seq.seq t) (i:nat{ i < Seq.length s0 /\ Seq.length s0 == Seq.length s1 }) : Lemma (requires Seq.equal (Seq.slice s0 0 i) (Seq.slice s1 0 i) /\ Seq.index s0 i == Seq.index s1 i) (ensures Seq.equal (Seq.slice s0 0 (i + 1)) (Seq.slice s1 0 (i + 1))) = assert (forall k. k < i ==> Seq.index s0 k == Seq.index (Seq.slice s0 0 i) k /\ Seq.index s1 k == Seq.index (Seq.slice s1 0 i) k) let extend_equal_up_to (#o:_) (#t:Type0) (#s0:Seq.seq t) (#s1:Seq.seq t) (len:US.t) (i:US.t{ Seq.length s0 == Seq.length s1 /\ US.(i <^ len) /\ US.v len == Seq.length s0 } ) : STGhost unit o (pure (equal_up_to s0 s1 (Some i))) (fun _ -> pure (equal_up_to s0 s1 (Some US.(i +^ 1sz)))) (requires Seq.index s0 (US.v i) == Seq.index s1 (US.v i)) (ensures fun _ -> True) = elim_pure _; extend_equal_up_to_lemma s0 s1 (US.v i); intro_pure (equal_up_to s0 s1 (Some US.(i +^ 1sz))) let extend_equal_up_to_neg (#o:_) (#t:Type0) (#s0:Seq.seq t) (#s1:Seq.seq t) (len:US.t) (i:US.t{ Seq.length s0 == Seq.length s1 /\ US.(i <^ len) /\ US.v len == Seq.length s0 } ) : STGhost unit o (pure (equal_up_to s0 s1 (Some i))) (fun _ -> pure (equal_up_to s0 s1 None)) (requires Seq.index s0 (US.v i) =!= Seq.index s1 (US.v i)) (ensures fun _ -> True) = elim_pure _; intro_pure _
{ "checked_file": "/", "dependencies": [ "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.HigherArray.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.fst" }
[ { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "Steel.ST.HigherArray", "short_module": "H" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 2, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a0: Steel.ST.Array.array t -> a1: Steel.ST.Array.array t -> l: FStar.SizeT.t -> ctr: Steel.ST.Reference.ref (FStar.Pervasives.Native.option FStar.SizeT.t) -> Steel.ST.Effect.Ghost.STGhost Prims.unit
Steel.ST.Effect.Ghost.STGhost
[]
[]
[ "Steel.Memory.inames", "Prims.eqtype", "Steel.FractionalPermission.perm", "Steel.ST.Array.array", "FStar.Seq.Base.seq", "FStar.SizeT.t", "Steel.ST.Reference.ref", "FStar.Pervasives.Native.option", "Steel.ST.Array.intro_exists_compare_inv", "FStar.Ghost.hide", "FStar.Pervasives.Native.Some", "FStar.SizeT.__uint_to_t", "Prims.unit", "Steel.ST.Util.rewrite", "Steel.ST.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Steel.ST.Util.intro_pure", "Steel.ST.Array.equal_up_to", "Steel.ST.Array.pts_to_length", "Steel.Effect.Common.star", "Steel.ST.Array.pts_to", "Steel.ST.Util.exists_", "Prims.bool", "Steel.ST.Array.compare_inv", "Steel.Effect.Common.vprop", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Steel.ST.Array.length", "Prims.eq2", "Prims.nat", "FStar.SizeT.v", "Prims.l_True" ]
[]
false
true
false
false
false
let init_compare_inv #o (#t: eqtype) (#p0: perm) (#p1: perm) (a0: array t) (a1: array t) (#s0: Seq.seq t) (#s1: Seq.seq t) (l: US.t) (ctr: R.ref (option US.t)) : STGhost unit o (let open US in ((pts_to a0 p0 s0) `star` (pts_to a1 p1 s1)) `star` (R.pts_to ctr Steel.FractionalPermission.full_perm (Some 0sz))) (fun _ -> exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr)) (requires (length a0 > 0 /\ length a0 == length a1 /\ US.v l == length a0)) (ensures (fun _ -> True)) =
pts_to_length a0 _; pts_to_length a1 _; intro_pure (equal_up_to s0 s1 (Ghost.hide (Some 0sz))); rewrite (R.pts_to ctr Steel.FractionalPermission.full_perm (Some 0sz)) (R.pts_to ctr Steel.FractionalPermission.full_perm (Ghost.hide (Some 0sz))); intro_exists_compare_inv a0 a1 l ctr (Ghost.hide (Some 0sz))
false
Steel.ST.Reference.fst
Steel.ST.Reference.with_local
val with_local (#t: Type) (init: t) (#pre: vprop) (#ret_t: Type) (#post: ret_t -> vprop) (body: (r: ref t) -> STT ret_t (pts_to r full_perm init `star` pre) (fun v -> exists_ (pts_to r full_perm) `star` post v) ) : STF ret_t pre post True (fun _ -> True)
val with_local (#t: Type) (init: t) (#pre: vprop) (#ret_t: Type) (#post: ret_t -> vprop) (body: (r: ref t) -> STT ret_t (pts_to r full_perm init `star` pre) (fun v -> exists_ (pts_to r full_perm) `star` post v) ) : STF ret_t pre post True (fun _ -> True)
let with_local (#t: Type) (init: t) (#pre: vprop) (#ret_t: Type) (#post: ret_t -> vprop) (body: (r: ref t) -> STT ret_t (pts_to r full_perm init `star` pre) (fun v -> exists_ (pts_to r full_perm) `star` post v) ) : STF ret_t pre post True (fun _ -> True) = _push_frame (); let r = _alloca init in let v = body r in let _ = elim_exists () in _free_and_pop_frame r; return v
{ "file_name": "lib/steel/Steel.ST.Reference.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 10, "end_line": 149, "start_col": 0, "start_line": 132 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Reference open FStar.Ghost open Steel.ST.Util open Steel.ST.Coercions module R = Steel.Reference let ref (a:Type0) : Type0 = R.ref a let null (#a:Type0) : ref a = R.null #a let is_null (#a:Type0) (r:ref a) : b:bool{b <==> r == null} = R.is_null r let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@smt_fallback] v:a) : vprop = R.pts_to r p v let pts_to_injective_eq (#a: Type) (#opened:inames) (#p0 #p1:perm) (#v0 #v1:a) (r: ref a) : STGhost unit opened (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0) (requires True) (ensures fun _ -> v0 == v1) = coerce_ghost (fun _ -> R.pts_to_injective_eq #a #opened #p0 #p1 #(hide v0) #(hide v1) r) let pts_to_not_null #a #opened #p #v r = extract_fact #opened (pts_to r p v) (r =!= null) (R.pts_to_not_null r p v); () let pts_to_perm r = coerce_ghost (fun _ -> R.pts_to_perm r) let alloc (#a:Type) (x:a) : ST (ref a) emp (fun r -> pts_to r full_perm x) (requires True) (ensures fun r -> not (is_null r)) = let r = coerce_steel (fun _ -> R.alloc_pt x) in r let read (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : ST a (pts_to r p v) (fun _ -> pts_to r p v) (requires True) (ensures fun x -> x == Ghost.reveal v) = let u = coerce_steel (fun _ -> R.read_pt r) in return u let write (#a:Type0) (#v:erased a) (r:ref a) (x:a) : STT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) = coerce_steel (fun _ -> R.write_pt r x); return () let free (#a:Type0) (#v:erased a) (r:ref a) : STT unit (pts_to r full_perm v) (fun _ -> emp) = coerce_steel(fun _ -> R.free_pt r); return () /// Local primitive, to be extracted to Low* EPushFrame. To remember /// that we need to call some pop_frame later, we insert some dummy /// vprop into the context. let _stack_frame : vprop = pure True let _push_frame () : STT unit emp (fun _ -> _stack_frame) = rewrite (pure True) _stack_frame /// Local primitive, to be extracted to Low* EBufCreate let _alloca (#a:Type) (x:a) : ST (ref a) emp (fun r -> pts_to r full_perm x) (requires True) (ensures fun r -> not (is_null r)) = alloc x /// Local primitive, to be extracted to Low* EPopFrame let _free_and_pop_frame (#a:Type0) (#v:erased a) (r:ref a) : STT unit (pts_to r full_perm v `star` _stack_frame) (fun _ -> emp) = free r; rewrite _stack_frame (pure True); elim_pure _
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Coercions.fsti.checked", "Steel.Reference.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Reference.fst" }
[ { "abbrev": true, "full_module": "Steel.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "Steel.ST.Coercions", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
init: t -> body: (r: Steel.ST.Reference.ref t -> Steel.ST.Effect.STT ret_t) -> Steel.ST.Effect.STF ret_t
Steel.ST.Effect.STF
[]
[]
[ "Steel.Effect.Common.vprop", "Steel.ST.Reference.ref", "Steel.Effect.Common.star", "Steel.ST.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Steel.ST.Util.exists_", "Steel.ST.Util.return", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Prims.unit", "Steel.ST.Reference._free_and_pop_frame", "FStar.Ghost.erased", "Steel.ST.Util.elim_exists", "Steel.ST.Reference._alloca", "Steel.ST.Reference._push_frame", "Prims.l_True" ]
[]
false
true
false
false
false
let with_local (#t: Type) (init: t) (#pre: vprop) (#ret_t: Type) (#post: (ret_t -> vprop)) (body: (r: ref t -> STT ret_t ((pts_to r full_perm init) `star` pre) (fun v -> (exists_ (pts_to r full_perm)) `star` (post v)))) : STF ret_t pre post True (fun _ -> True) =
_push_frame (); let r = _alloca init in let v = body r in let _ = elim_exists () in _free_and_pop_frame r; return v
false
CQueue.fst
CQueue.elim_llist_fragment_head_nil
val elim_llist_fragment_head_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost unit opened (llist_fragment_head l phead head) (fun _ -> emp) (fun _ -> Nil? l) (fun h _ _ -> sel_llist_fragment_head l phead head h == (phead, head))
val elim_llist_fragment_head_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost unit opened (llist_fragment_head l phead head) (fun _ -> emp) (fun _ -> Nil? l) (fun h _ _ -> sel_llist_fragment_head l phead head h == (phead, head))
let elim_llist_fragment_head_nil l phead head = change_equal_slprop (llist_fragment_head l phead head) (vconst (phead, head)); elim_vconst (phead, head)
{ "file_name": "share/steel/examples/steel/CQueue.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 27, "end_line": 822, "start_col": 0, "start_line": 816 }
module CQueue open CQueue.LList #set-options "--ide_id_info_off" //Re-define squash, since this module explicitly //replies on proving equalities of the form `t_of v == squash p` //which are delicate in the presence of optimizations that //unfold `Prims.squash (p /\ q)`to _:unit{p /\ q} //See Issue #2496 let squash (p:Type u#a) : Type0 = squash p (* BEGIN library *) let intro_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: (t_of v) -> GTot t) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v)) = intro_vrewrite v f let elim_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened (vrewrite v f) (fun _ -> v) (fun _ -> True) (fun h _ h' -> h (vrewrite v f) == f (h' v)) = elim_vrewrite v f let vconst_sel (#a: Type) (x: a) : Tot (selector a (hp_of emp)) = fun _ -> x [@@ __steel_reduce__] let vconst' (#a: Type) (x: a) : GTot vprop' = { hp = hp_of emp; t = a; sel = vconst_sel x; } [@@ __steel_reduce__] let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x) let intro_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened emp (fun _ -> vconst x) (fun _ -> True) (fun _ _ h' -> h' (vconst x) == x) = change_slprop_rel emp (vconst x) (fun _ y -> y == x) (fun _ -> ()) let elim_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened (vconst x) (fun _ -> emp) (fun _ -> True) (fun h _ _ -> h (vconst x) == x) = change_slprop_rel (vconst x) emp (fun y _ -> y == x) (fun _ -> ()) let vpure_sel' (p: prop) : Tot (selector' (squash p) (Steel.Memory.pure p)) = fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m let vpure_sel (p: prop) : Tot (selector (squash p) (Steel.Memory.pure p)) = vpure_sel' p [@@ __steel_reduce__] let vpure' (p: prop) : GTot vprop' = { hp = Steel.Memory.pure p; t = squash p; sel = vpure_sel p; } [@@ __steel_reduce__] let vpure (p: prop) : Tot vprop = VUnit (vpure' p) let intro_vpure (#opened: _) (p: prop) : SteelGhost unit opened emp (fun _ -> vpure p) (fun _ -> p) (fun _ _ h' -> p) = change_slprop_rel emp (vpure p) (fun _ _ -> p) (fun m -> pure_interp p m) let elim_vpure (#opened: _) (p: prop) : SteelGhost unit opened (vpure p) (fun _ -> emp) (fun _ -> True) (fun _ _ _ -> p) = change_slprop_rel (vpure p) emp (fun _ _ -> p) (fun m -> pure_interp p m; reveal_emp (); intro_emp m) val intro_vdep2 (#opened:inames) (v: vprop) (q: vprop) (x: t_of v) (p: (t_of v -> Tot vprop)) : SteelGhost unit opened (v `star` q) (fun _ -> vdep v p) (requires (fun h -> q == p x /\ x == h v )) (ensures (fun h _ h' -> let x2 = h' (vdep v p) in q == p (h v) /\ dfst x2 == (h v) /\ dsnd x2 == (h q) )) let intro_vdep2 v q x p = intro_vdep v q p let vbind0_payload (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: t_of a) : Tot vprop = vpure (t == t_of (b x)) `star` b x let vbind0_rewrite (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: normal (t_of (vdep a (vbind0_payload a t b)))) : Tot t = snd (dsnd x) [@@__steel_reduce__; __reduce__] let vbind0 (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop = a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b let vbind_hp // necessary to hide the attribute on hp_of (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot (slprop u#1) = hp_of (vbind0 a t b) let vbind_sel // same for hp_sel (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot (selector t (vbind_hp a t b)) = sel_of (vbind0 a t b) [@@__steel_reduce__] let vbind' (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot vprop' = { hp = vbind_hp a t b; t = t; sel = vbind_sel a t b; } [@@__steel_reduce__] let vbind (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop = VUnit (vbind' a t b) let intro_vbind (#opened: _) (a: vprop) (b' : vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : SteelGhost unit opened (a `star` b') (fun _ -> vbind a t b) (fun h -> t_of b' == t /\ b' == b (h a)) (fun h _ h' -> t_of b' == t /\ b' == b (h a) /\ h' (vbind a t b) == h b' ) = intro_vpure (t == t_of b'); intro_vdep a (vpure (t == t_of b') `star` b') (vbind0_payload a t b); intro_vrewrite (a `vdep` vbind0_payload a t b) (vbind0_rewrite a t b); change_slprop_rel (vbind0 a t b) (vbind a t b) (fun x y -> x == y) (fun _ -> ()) let elim_vbind (#opened: _) (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : SteelGhost (Ghost.erased (t_of a)) opened (vbind a t b) (fun res -> a `star` b (Ghost.reveal res)) (fun h -> True) (fun h res h' -> h' a == Ghost.reveal res /\ t == t_of (b (Ghost.reveal res)) /\ h' (b (Ghost.reveal res)) == h (vbind a t b) ) = change_slprop_rel (vbind a t b) (vbind0 a t b) (fun x y -> x == y) (fun _ -> ()); elim_vrewrite (a `vdep` vbind0_payload a t b) (vbind0_rewrite a t b); let res = elim_vdep a (vbind0_payload a t b) in change_equal_slprop (vbind0_payload a t b (Ghost.reveal res)) (vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res)); elim_vpure (t == t_of (b (Ghost.reveal res))); res let (==) (#a:_) (x y: a) : prop = x == y let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma (requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2])) (ensures (hd1 == hd2 /\ tl1 == tl2)) [SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])] = L.lemma_snoc_unsnoc (hd1, tl1); L.lemma_snoc_unsnoc (hd2, tl2) [@"opaque_to_smt"] let unsnoc (#a: Type) (l: list a) : Pure (list a & a) (requires (Cons? l)) (ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l)) = L.lemma_unsnoc_snoc l; L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)]; L.unsnoc l let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' < L.length l)) = fst (unsnoc l) let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l) [@@"opaque_to_smt"] let snoc (#a: Type) (l: list a) (x: a) : Pure (list a) (requires True) (ensures (fun l' -> Cons? l' /\ unsnoc_hd l' == l /\ unsnoc_tl l' == x )) = let l' = L.snoc (l, x) in L.append_length l [x]; snoc_inj l (unsnoc_hd l') x (unsnoc_tl l'); l' let snoc_unsnoc (#a: Type) (l: list a) : Lemma (requires (Cons? l)) (ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l)) = () unfold let coerce (#a: Type) (x: a) (b: Type) : Pure b (requires (a == b)) (ensures (fun y -> a == b /\ x == y)) = x (* END library *) let t a = cllist_lvalue a let v (a: Type0) = list a let datas (#a: Type0) (l: v a) : Tot (list a) = l (* view from the tail *) let llist_fragment_tail_cons_data_refine (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (d: a) : Tot prop = d == unsnoc_tl (Ghost.reveal l) [@@ __steel_reduce__] let llist_fragment_tail_cons_lvalue_payload (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (c: ccell_lvalue a) : Tot vprop = vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l let ccell_is_lvalue_refine (a: Type) (c: ccell_ptrvalue a) : Tot prop = ccell_ptrvalue_is_null c == false [@@ __steel_reduce__ ] let llist_fragment_tail_cons_next_payload (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (ptail: ref (ccell_ptrvalue a)) : Tot vprop = vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l [@@ __steel_reduce__ ] let llist_fragment_tail_cons_rewrite (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) }) (x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l)))) : Tot (ref (ccell_ptrvalue a)) = let (| _, (| c, _ |) |) = x in ccell_next c let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop (requires True) (ensures (fun v -> t_of v == ref (ccell_ptrvalue a))) (decreases (Ghost.reveal (L.length l))) = if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) let llist_fragment_tail_eq (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Lemma (llist_fragment_tail l phead == ( if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) )) = assert_norm (llist_fragment_tail l phead == ( if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) )) let llist_fragment_tail_eq_cons (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Lemma (requires (Cons? l)) (ensures (Cons? l /\ llist_fragment_tail l phead == ( llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) ))) = llist_fragment_tail_eq l phead unfold let sel_llist_fragment_tail (#a:Type) (#p:vprop) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) }) : GTot (ref (ccell_ptrvalue a)) = coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a)) val intro_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened emp (fun _ -> llist_fragment_tail l phead) (fun _ -> Nil? l) (fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead) let intro_llist_fragment_tail_nil l phead = intro_vconst phead; change_equal_slprop (vconst phead) (llist_fragment_tail l phead) val elim_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_tail l phead) (fun _ -> emp) (fun _ -> Nil? l) (fun h _ _ -> sel_llist_fragment_tail l phead h == phead) let elim_llist_fragment_tail_nil l phead = change_equal_slprop (llist_fragment_tail l phead) (vconst phead); elim_vconst phead val intro_llist_fragment_tail_snoc (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (ptail: Ghost.erased (ref (ccell_ptrvalue a))) (tail: Ghost.erased (ccell_lvalue a)) : SteelGhost (Ghost.erased (list a)) opened (llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail)) (fun res -> llist_fragment_tail res phead) (fun h -> sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\ sel ptail h == Ghost.reveal tail ) (fun h res h' -> Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\ sel_llist_fragment_tail res phead h' == ccell_next tail ) #push-options "--z3rlimit 16" let intro_llist_fragment_tail_snoc #_ #a l phead ptail tail = let d = gget (vptr (ccell_data tail)) in let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l'); intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a); intro_vdep (vptr ptail `vrefine` ccell_is_lvalue_refine a) (vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l') (llist_fragment_tail_cons_lvalue_payload l'); change_equal_slprop (llist_fragment_tail l phead) (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead); intro_vdep (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead) (vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l') (llist_fragment_tail_cons_next_payload l'); intro_vrewrite_no_norm (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l') (llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)); llist_fragment_tail_eq_cons l' phead; change_equal_slprop (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)) (llist_fragment_tail l' phead); let g' = gget (llist_fragment_tail l' phead) in assert (Ghost.reveal g' == ccell_next tail); noop (); l' #pop-options [@@erasable] noeq type ll_unsnoc_t (a: Type) = { ll_unsnoc_l: list a; ll_unsnoc_ptail: ref (ccell_ptrvalue a); ll_unsnoc_tail: ccell_lvalue a; } val elim_llist_fragment_tail_snoc (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost (ll_unsnoc_t a) opened (llist_fragment_tail l phead) (fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail)) (fun _ -> Cons? l) (fun h res h' -> Cons? l /\ Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\ sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\ sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\ sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\ sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail) ) #push-options "--z3rlimit 32" #restart-solver let elim_llist_fragment_tail_snoc #_ #a l phead = let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in llist_fragment_tail_eq_cons l0 phead; change_equal_slprop (llist_fragment_tail l phead) (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)); elim_vrewrite_no_norm (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0) (llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)); let ptail = elim_vdep (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead) (llist_fragment_tail_cons_next_payload l0) in let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in change_equal_slprop (llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail)) (vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0); let tail = elim_vdep (vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a) (llist_fragment_tail_cons_lvalue_payload l0) in elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a); let res = { ll_unsnoc_l = unsnoc_hd l0; ll_unsnoc_ptail = Ghost.reveal ptail0; ll_unsnoc_tail = Ghost.reveal tail; } in change_equal_slprop (vptr (Ghost.reveal ptail0)) (vptr res.ll_unsnoc_ptail); change_equal_slprop (llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail)) (vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0); elim_vrefine (vptr (ccell_data res.ll_unsnoc_tail)) (llist_fragment_tail_cons_data_refine l0); change_equal_slprop (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead) (llist_fragment_tail res.ll_unsnoc_l phead); res #pop-options let rec llist_fragment_tail_append (#opened: _) (#a: Type) (phead0: ref (ccell_ptrvalue a)) (l1: Ghost.erased (list a)) (phead1: Ghost.erased (ref (ccell_ptrvalue a))) (l2: Ghost.erased (list a)) : SteelGhost (Ghost.erased (list a)) opened (llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1) (fun res -> llist_fragment_tail res phead0) (fun h -> Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h ) (fun h res h' -> Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\ (sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h ) (decreases (L.length (Ghost.reveal l2))) = let g1 = gget (llist_fragment_tail l1 phead0) in assert (Ghost.reveal phead1 == Ghost.reveal g1); if Nil? l2 then begin L.append_l_nil (Ghost.reveal l1); elim_llist_fragment_tail_nil l2 phead1; l1 end else begin let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d]; let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail end let queue_tail_refine (#a: Type) (tail1: ref (ccell_ptrvalue a)) (tail2: ref (ccell_ptrvalue a)) (tl: normal (t_of (vptr tail2))) : Tot prop = ccell_ptrvalue_is_null tl == true /\ tail1 == tail2 [@@__steel_reduce__] let queue_tail_dep2 (#a: Type) (x: t a) (l: Ghost.erased (list a)) (tail1: t_of (llist_fragment_tail l (cllist_head x))) (tail2: ref (ccell_ptrvalue a)) : Tot vprop = vptr tail2 `vrefine` queue_tail_refine tail1 tail2 [@@__steel_reduce__] let queue_tail_dep1 (#a: Type) (x: t a) (l: Ghost.erased (list a)) (tail1: t_of (llist_fragment_tail l (cllist_head x))) : Tot vprop = vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1 [@@__steel_reduce__; __reduce__] let queue_tail (#a: Type) (x: t a) (l: Ghost.erased (list a)) : Tot vprop = llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l val intro_queue_tail (#opened: _) (#a: Type) (x: t a) (l: Ghost.erased (list a)) (tail: ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail) (fun _ -> queue_tail x l) (fun h -> sel_llist_fragment_tail l (cllist_head x) h == tail /\ sel (cllist_tail x) h == tail /\ ccell_ptrvalue_is_null (sel tail h) ) (fun _ _ _ -> True) let intro_queue_tail x l tail = intro_vrefine (vptr tail) (queue_tail_refine tail tail); intro_vdep2 (vptr (cllist_tail x)) (vptr tail `vrefine` queue_tail_refine tail tail) tail (queue_tail_dep2 x l tail); intro_vdep2 (llist_fragment_tail l (cllist_head x)) (vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail) tail (queue_tail_dep1 x l) val elim_queue_tail (#opened: _) (#a: Type) (x: t a) (l: Ghost.erased (list a)) : SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened (queue_tail x l) (fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail) (fun h -> True) (fun _ tail h -> sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\ sel (cllist_tail x) h == Ghost.reveal tail /\ ccell_ptrvalue_is_null (h (vptr tail)) ) let elim_queue_tail #_ #a x l = let tail0 = elim_vdep (llist_fragment_tail l (cllist_head x)) (queue_tail_dep1 x l) in let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in change_equal_slprop (queue_tail_dep1 x l (Ghost.reveal tail0)) (vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0); let tail2 = elim_vdep (vptr (cllist_tail x)) (queue_tail_dep2 x l tail0) in let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in change_equal_slprop (queue_tail_dep2 x l tail0 (Ghost.reveal tail2)) (vptr tail3 `vrefine` queue_tail_refine tail0 tail3); elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3); change_equal_slprop (vptr tail3) (vptr tail); tail (* view from the head *) let llist_fragment_head_data_refine (#a: Type) (d: a) (c: vcell a) : Tot prop = c.vcell_data == d let llist_fragment_head_payload (#a: Type) (head: ccell_ptrvalue a) (d: a) (llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop)) (x: t_of (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine d))) : Tot vprop = llist_fragment_head (ccell_next (fst x)) (snd x).vcell_next let rec llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Tot vprop (decreases (Ghost.reveal l)) = if Nil? l then vconst (phead, head) else vbind (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l)))) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) (llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l)))) let t_of_llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Lemma (t_of (llist_fragment_head l phead head) == ref (ccell_ptrvalue a) & ccell_ptrvalue a) = () unfold let sel_llist_fragment_head (#a:Type) (#p:vprop) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) (h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_head l phead head) /\ True) }) : GTot (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = coerce (h (llist_fragment_head l phead head)) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) val intro_llist_fragment_head_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost unit opened emp (fun _ -> llist_fragment_head l phead head) (fun _ -> Nil? l) (fun _ _ h' -> sel_llist_fragment_head l phead head h' == (phead, head)) let intro_llist_fragment_head_nil l phead head = intro_vconst (phead, head); change_equal_slprop (vconst (phead, head)) (llist_fragment_head l phead head) val elim_llist_fragment_head_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost unit opened (llist_fragment_head l phead head) (fun _ -> emp) (fun _ -> Nil? l) (fun h _ _ -> sel_llist_fragment_head l phead head h == (phead, head))
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "CQueue.LList.fsti.checked" ], "interface_file": true, "source_file": "CQueue.fst" }
[ { "abbrev": false, "full_module": "CQueue.LList", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: FStar.Ghost.erased (Prims.list a) -> phead: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) -> head: CQueue.Cell.ccell_ptrvalue a -> Steel.Effect.Atomic.SteelGhost Prims.unit
Steel.Effect.Atomic.SteelGhost
[]
[]
[ "Steel.Memory.inames", "FStar.Ghost.erased", "Prims.list", "Steel.Reference.ref", "CQueue.Cell.ccell_ptrvalue", "CQueue.elim_vconst", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "Steel.Effect.Atomic.change_equal_slprop", "CQueue.llist_fragment_head", "CQueue.vconst" ]
[]
false
true
false
false
false
let elim_llist_fragment_head_nil l phead head =
change_equal_slprop (llist_fragment_head l phead head) (vconst (phead, head)); elim_vconst (phead, head)
false
CQueue.fst
CQueue.elim_llist_fragment_tail_nil
val elim_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_tail l phead) (fun _ -> emp) (fun _ -> Nil? l) (fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
val elim_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_tail l phead) (fun _ -> emp) (fun _ -> Nil? l) (fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil l phead = change_equal_slprop (llist_fragment_tail l phead) (vconst phead); elim_vconst phead
{ "file_name": "share/steel/examples/steel/CQueue.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 19, "end_line": 464, "start_col": 0, "start_line": 458 }
module CQueue open CQueue.LList #set-options "--ide_id_info_off" //Re-define squash, since this module explicitly //replies on proving equalities of the form `t_of v == squash p` //which are delicate in the presence of optimizations that //unfold `Prims.squash (p /\ q)`to _:unit{p /\ q} //See Issue #2496 let squash (p:Type u#a) : Type0 = squash p (* BEGIN library *) let intro_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: (t_of v) -> GTot t) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v)) = intro_vrewrite v f let elim_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened (vrewrite v f) (fun _ -> v) (fun _ -> True) (fun h _ h' -> h (vrewrite v f) == f (h' v)) = elim_vrewrite v f let vconst_sel (#a: Type) (x: a) : Tot (selector a (hp_of emp)) = fun _ -> x [@@ __steel_reduce__] let vconst' (#a: Type) (x: a) : GTot vprop' = { hp = hp_of emp; t = a; sel = vconst_sel x; } [@@ __steel_reduce__] let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x) let intro_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened emp (fun _ -> vconst x) (fun _ -> True) (fun _ _ h' -> h' (vconst x) == x) = change_slprop_rel emp (vconst x) (fun _ y -> y == x) (fun _ -> ()) let elim_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened (vconst x) (fun _ -> emp) (fun _ -> True) (fun h _ _ -> h (vconst x) == x) = change_slprop_rel (vconst x) emp (fun y _ -> y == x) (fun _ -> ()) let vpure_sel' (p: prop) : Tot (selector' (squash p) (Steel.Memory.pure p)) = fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m let vpure_sel (p: prop) : Tot (selector (squash p) (Steel.Memory.pure p)) = vpure_sel' p [@@ __steel_reduce__] let vpure' (p: prop) : GTot vprop' = { hp = Steel.Memory.pure p; t = squash p; sel = vpure_sel p; } [@@ __steel_reduce__] let vpure (p: prop) : Tot vprop = VUnit (vpure' p) let intro_vpure (#opened: _) (p: prop) : SteelGhost unit opened emp (fun _ -> vpure p) (fun _ -> p) (fun _ _ h' -> p) = change_slprop_rel emp (vpure p) (fun _ _ -> p) (fun m -> pure_interp p m) let elim_vpure (#opened: _) (p: prop) : SteelGhost unit opened (vpure p) (fun _ -> emp) (fun _ -> True) (fun _ _ _ -> p) = change_slprop_rel (vpure p) emp (fun _ _ -> p) (fun m -> pure_interp p m; reveal_emp (); intro_emp m) val intro_vdep2 (#opened:inames) (v: vprop) (q: vprop) (x: t_of v) (p: (t_of v -> Tot vprop)) : SteelGhost unit opened (v `star` q) (fun _ -> vdep v p) (requires (fun h -> q == p x /\ x == h v )) (ensures (fun h _ h' -> let x2 = h' (vdep v p) in q == p (h v) /\ dfst x2 == (h v) /\ dsnd x2 == (h q) )) let intro_vdep2 v q x p = intro_vdep v q p let vbind0_payload (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: t_of a) : Tot vprop = vpure (t == t_of (b x)) `star` b x let vbind0_rewrite (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: normal (t_of (vdep a (vbind0_payload a t b)))) : Tot t = snd (dsnd x) [@@__steel_reduce__; __reduce__] let vbind0 (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop = a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b let vbind_hp // necessary to hide the attribute on hp_of (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot (slprop u#1) = hp_of (vbind0 a t b) let vbind_sel // same for hp_sel (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot (selector t (vbind_hp a t b)) = sel_of (vbind0 a t b) [@@__steel_reduce__] let vbind' (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot vprop' = { hp = vbind_hp a t b; t = t; sel = vbind_sel a t b; } [@@__steel_reduce__] let vbind (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop = VUnit (vbind' a t b) let intro_vbind (#opened: _) (a: vprop) (b' : vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : SteelGhost unit opened (a `star` b') (fun _ -> vbind a t b) (fun h -> t_of b' == t /\ b' == b (h a)) (fun h _ h' -> t_of b' == t /\ b' == b (h a) /\ h' (vbind a t b) == h b' ) = intro_vpure (t == t_of b'); intro_vdep a (vpure (t == t_of b') `star` b') (vbind0_payload a t b); intro_vrewrite (a `vdep` vbind0_payload a t b) (vbind0_rewrite a t b); change_slprop_rel (vbind0 a t b) (vbind a t b) (fun x y -> x == y) (fun _ -> ()) let elim_vbind (#opened: _) (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : SteelGhost (Ghost.erased (t_of a)) opened (vbind a t b) (fun res -> a `star` b (Ghost.reveal res)) (fun h -> True) (fun h res h' -> h' a == Ghost.reveal res /\ t == t_of (b (Ghost.reveal res)) /\ h' (b (Ghost.reveal res)) == h (vbind a t b) ) = change_slprop_rel (vbind a t b) (vbind0 a t b) (fun x y -> x == y) (fun _ -> ()); elim_vrewrite (a `vdep` vbind0_payload a t b) (vbind0_rewrite a t b); let res = elim_vdep a (vbind0_payload a t b) in change_equal_slprop (vbind0_payload a t b (Ghost.reveal res)) (vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res)); elim_vpure (t == t_of (b (Ghost.reveal res))); res let (==) (#a:_) (x y: a) : prop = x == y let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma (requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2])) (ensures (hd1 == hd2 /\ tl1 == tl2)) [SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])] = L.lemma_snoc_unsnoc (hd1, tl1); L.lemma_snoc_unsnoc (hd2, tl2) [@"opaque_to_smt"] let unsnoc (#a: Type) (l: list a) : Pure (list a & a) (requires (Cons? l)) (ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l)) = L.lemma_unsnoc_snoc l; L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)]; L.unsnoc l let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' < L.length l)) = fst (unsnoc l) let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l) [@@"opaque_to_smt"] let snoc (#a: Type) (l: list a) (x: a) : Pure (list a) (requires True) (ensures (fun l' -> Cons? l' /\ unsnoc_hd l' == l /\ unsnoc_tl l' == x )) = let l' = L.snoc (l, x) in L.append_length l [x]; snoc_inj l (unsnoc_hd l') x (unsnoc_tl l'); l' let snoc_unsnoc (#a: Type) (l: list a) : Lemma (requires (Cons? l)) (ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l)) = () unfold let coerce (#a: Type) (x: a) (b: Type) : Pure b (requires (a == b)) (ensures (fun y -> a == b /\ x == y)) = x (* END library *) let t a = cllist_lvalue a let v (a: Type0) = list a let datas (#a: Type0) (l: v a) : Tot (list a) = l (* view from the tail *) let llist_fragment_tail_cons_data_refine (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (d: a) : Tot prop = d == unsnoc_tl (Ghost.reveal l) [@@ __steel_reduce__] let llist_fragment_tail_cons_lvalue_payload (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (c: ccell_lvalue a) : Tot vprop = vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l let ccell_is_lvalue_refine (a: Type) (c: ccell_ptrvalue a) : Tot prop = ccell_ptrvalue_is_null c == false [@@ __steel_reduce__ ] let llist_fragment_tail_cons_next_payload (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (ptail: ref (ccell_ptrvalue a)) : Tot vprop = vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l [@@ __steel_reduce__ ] let llist_fragment_tail_cons_rewrite (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) }) (x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l)))) : Tot (ref (ccell_ptrvalue a)) = let (| _, (| c, _ |) |) = x in ccell_next c let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop (requires True) (ensures (fun v -> t_of v == ref (ccell_ptrvalue a))) (decreases (Ghost.reveal (L.length l))) = if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) let llist_fragment_tail_eq (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Lemma (llist_fragment_tail l phead == ( if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) )) = assert_norm (llist_fragment_tail l phead == ( if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) )) let llist_fragment_tail_eq_cons (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Lemma (requires (Cons? l)) (ensures (Cons? l /\ llist_fragment_tail l phead == ( llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) ))) = llist_fragment_tail_eq l phead unfold let sel_llist_fragment_tail (#a:Type) (#p:vprop) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) }) : GTot (ref (ccell_ptrvalue a)) = coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a)) val intro_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened emp (fun _ -> llist_fragment_tail l phead) (fun _ -> Nil? l) (fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead) let intro_llist_fragment_tail_nil l phead = intro_vconst phead; change_equal_slprop (vconst phead) (llist_fragment_tail l phead) val elim_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_tail l phead) (fun _ -> emp) (fun _ -> Nil? l) (fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "CQueue.LList.fsti.checked" ], "interface_file": true, "source_file": "CQueue.fst" }
[ { "abbrev": false, "full_module": "CQueue.LList", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: FStar.Ghost.erased (Prims.list a) -> phead: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) -> Steel.Effect.Atomic.SteelGhost Prims.unit
Steel.Effect.Atomic.SteelGhost
[]
[]
[ "Steel.Memory.inames", "FStar.Ghost.erased", "Prims.list", "Steel.Reference.ref", "CQueue.Cell.ccell_ptrvalue", "CQueue.elim_vconst", "Prims.unit", "Steel.Effect.Atomic.change_equal_slprop", "CQueue.llist_fragment_tail", "CQueue.vconst" ]
[]
false
true
false
false
false
let elim_llist_fragment_tail_nil l phead =
change_equal_slprop (llist_fragment_tail l phead) (vconst phead); elim_vconst phead
false
Steel.ST.Reference.fst
Steel.ST.Reference.with_named_local
val with_named_local (#t: Type) (init: t) (#pre: vprop) (#ret_t: Type) (#post: ret_t -> vprop) (name: string) (body: (r: ref t) -> STT ret_t (pts_to r full_perm init `star` pre) (fun v -> exists_ (pts_to r full_perm) `star` post v) ) : STF ret_t pre post True (fun _ -> True)
val with_named_local (#t: Type) (init: t) (#pre: vprop) (#ret_t: Type) (#post: ret_t -> vprop) (name: string) (body: (r: ref t) -> STT ret_t (pts_to r full_perm init `star` pre) (fun v -> exists_ (pts_to r full_perm) `star` post v) ) : STF ret_t pre post True (fun _ -> True)
let with_named_local (#t: Type) (init: t) (#pre: vprop) (#ret_t: Type) (#post: ret_t -> vprop) (name: string) (body: (r: ref t) -> STT ret_t (pts_to r full_perm init `star` pre) (fun v -> exists_ (pts_to r full_perm) `star` post v) ) : STF ret_t pre post True (fun _ -> True) = _push_frame (); [@(rename_let name)] let r = _alloca init in let v = body r in let _ = elim_exists () in _free_and_pop_frame r; return v
{ "file_name": "lib/steel/Steel.ST.Reference.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 10, "end_line": 170, "start_col": 0, "start_line": 151 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Reference open FStar.Ghost open Steel.ST.Util open Steel.ST.Coercions module R = Steel.Reference let ref (a:Type0) : Type0 = R.ref a let null (#a:Type0) : ref a = R.null #a let is_null (#a:Type0) (r:ref a) : b:bool{b <==> r == null} = R.is_null r let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@smt_fallback] v:a) : vprop = R.pts_to r p v let pts_to_injective_eq (#a: Type) (#opened:inames) (#p0 #p1:perm) (#v0 #v1:a) (r: ref a) : STGhost unit opened (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0) (requires True) (ensures fun _ -> v0 == v1) = coerce_ghost (fun _ -> R.pts_to_injective_eq #a #opened #p0 #p1 #(hide v0) #(hide v1) r) let pts_to_not_null #a #opened #p #v r = extract_fact #opened (pts_to r p v) (r =!= null) (R.pts_to_not_null r p v); () let pts_to_perm r = coerce_ghost (fun _ -> R.pts_to_perm r) let alloc (#a:Type) (x:a) : ST (ref a) emp (fun r -> pts_to r full_perm x) (requires True) (ensures fun r -> not (is_null r)) = let r = coerce_steel (fun _ -> R.alloc_pt x) in r let read (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : ST a (pts_to r p v) (fun _ -> pts_to r p v) (requires True) (ensures fun x -> x == Ghost.reveal v) = let u = coerce_steel (fun _ -> R.read_pt r) in return u let write (#a:Type0) (#v:erased a) (r:ref a) (x:a) : STT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) = coerce_steel (fun _ -> R.write_pt r x); return () let free (#a:Type0) (#v:erased a) (r:ref a) : STT unit (pts_to r full_perm v) (fun _ -> emp) = coerce_steel(fun _ -> R.free_pt r); return () /// Local primitive, to be extracted to Low* EPushFrame. To remember /// that we need to call some pop_frame later, we insert some dummy /// vprop into the context. let _stack_frame : vprop = pure True let _push_frame () : STT unit emp (fun _ -> _stack_frame) = rewrite (pure True) _stack_frame /// Local primitive, to be extracted to Low* EBufCreate let _alloca (#a:Type) (x:a) : ST (ref a) emp (fun r -> pts_to r full_perm x) (requires True) (ensures fun r -> not (is_null r)) = alloc x /// Local primitive, to be extracted to Low* EPopFrame let _free_and_pop_frame (#a:Type0) (#v:erased a) (r:ref a) : STT unit (pts_to r full_perm v `star` _stack_frame) (fun _ -> emp) = free r; rewrite _stack_frame (pure True); elim_pure _ let with_local (#t: Type) (init: t) (#pre: vprop) (#ret_t: Type) (#post: ret_t -> vprop) (body: (r: ref t) -> STT ret_t (pts_to r full_perm init `star` pre) (fun v -> exists_ (pts_to r full_perm) `star` post v) ) : STF ret_t pre post True (fun _ -> True) = _push_frame (); let r = _alloca init in let v = body r in let _ = elim_exists () in _free_and_pop_frame r; return v
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Coercions.fsti.checked", "Steel.Reference.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Reference.fst" }
[ { "abbrev": true, "full_module": "Steel.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "Steel.ST.Coercions", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
init: t -> name: Prims.string -> body: (r: Steel.ST.Reference.ref t -> Steel.ST.Effect.STT ret_t) -> Steel.ST.Effect.STF ret_t
Steel.ST.Effect.STF
[]
[]
[ "Steel.Effect.Common.vprop", "Prims.string", "Steel.ST.Reference.ref", "Steel.Effect.Common.star", "Steel.ST.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Steel.ST.Util.exists_", "Steel.ST.Util.return", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Prims.unit", "Steel.ST.Reference._free_and_pop_frame", "FStar.Ghost.erased", "Steel.ST.Util.elim_exists", "Steel.ST.Reference._alloca", "Steel.ST.Reference._push_frame", "Prims.l_True" ]
[]
false
true
false
false
false
let with_named_local (#t: Type) (init: t) (#pre: vprop) (#ret_t: Type) (#post: (ret_t -> vprop)) (name: string) (body: (r: ref t -> STT ret_t ((pts_to r full_perm init) `star` pre) (fun v -> (exists_ (pts_to r full_perm)) `star` (post v)))) : STF ret_t pre post True (fun _ -> True) =
_push_frame (); [@@ (rename_let name) ]let r = _alloca init in let v = body r in let _ = elim_exists () in _free_and_pop_frame r; return v
false
CQueue.fst
CQueue.intro_llist_fragment_head_nil
val intro_llist_fragment_head_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost unit opened emp (fun _ -> llist_fragment_head l phead head) (fun _ -> Nil? l) (fun _ _ h' -> sel_llist_fragment_head l phead head h' == (phead, head))
val intro_llist_fragment_head_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost unit opened emp (fun _ -> llist_fragment_head l phead head) (fun _ -> Nil? l) (fun _ _ h' -> sel_llist_fragment_head l phead head h' == (phead, head))
let intro_llist_fragment_head_nil l phead head = intro_vconst (phead, head); change_equal_slprop (vconst (phead, head)) (llist_fragment_head l phead head)
{ "file_name": "share/steel/examples/steel/CQueue.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 38, "end_line": 802, "start_col": 0, "start_line": 796 }
module CQueue open CQueue.LList #set-options "--ide_id_info_off" //Re-define squash, since this module explicitly //replies on proving equalities of the form `t_of v == squash p` //which are delicate in the presence of optimizations that //unfold `Prims.squash (p /\ q)`to _:unit{p /\ q} //See Issue #2496 let squash (p:Type u#a) : Type0 = squash p (* BEGIN library *) let intro_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: (t_of v) -> GTot t) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v)) = intro_vrewrite v f let elim_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened (vrewrite v f) (fun _ -> v) (fun _ -> True) (fun h _ h' -> h (vrewrite v f) == f (h' v)) = elim_vrewrite v f let vconst_sel (#a: Type) (x: a) : Tot (selector a (hp_of emp)) = fun _ -> x [@@ __steel_reduce__] let vconst' (#a: Type) (x: a) : GTot vprop' = { hp = hp_of emp; t = a; sel = vconst_sel x; } [@@ __steel_reduce__] let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x) let intro_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened emp (fun _ -> vconst x) (fun _ -> True) (fun _ _ h' -> h' (vconst x) == x) = change_slprop_rel emp (vconst x) (fun _ y -> y == x) (fun _ -> ()) let elim_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened (vconst x) (fun _ -> emp) (fun _ -> True) (fun h _ _ -> h (vconst x) == x) = change_slprop_rel (vconst x) emp (fun y _ -> y == x) (fun _ -> ()) let vpure_sel' (p: prop) : Tot (selector' (squash p) (Steel.Memory.pure p)) = fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m let vpure_sel (p: prop) : Tot (selector (squash p) (Steel.Memory.pure p)) = vpure_sel' p [@@ __steel_reduce__] let vpure' (p: prop) : GTot vprop' = { hp = Steel.Memory.pure p; t = squash p; sel = vpure_sel p; } [@@ __steel_reduce__] let vpure (p: prop) : Tot vprop = VUnit (vpure' p) let intro_vpure (#opened: _) (p: prop) : SteelGhost unit opened emp (fun _ -> vpure p) (fun _ -> p) (fun _ _ h' -> p) = change_slprop_rel emp (vpure p) (fun _ _ -> p) (fun m -> pure_interp p m) let elim_vpure (#opened: _) (p: prop) : SteelGhost unit opened (vpure p) (fun _ -> emp) (fun _ -> True) (fun _ _ _ -> p) = change_slprop_rel (vpure p) emp (fun _ _ -> p) (fun m -> pure_interp p m; reveal_emp (); intro_emp m) val intro_vdep2 (#opened:inames) (v: vprop) (q: vprop) (x: t_of v) (p: (t_of v -> Tot vprop)) : SteelGhost unit opened (v `star` q) (fun _ -> vdep v p) (requires (fun h -> q == p x /\ x == h v )) (ensures (fun h _ h' -> let x2 = h' (vdep v p) in q == p (h v) /\ dfst x2 == (h v) /\ dsnd x2 == (h q) )) let intro_vdep2 v q x p = intro_vdep v q p let vbind0_payload (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: t_of a) : Tot vprop = vpure (t == t_of (b x)) `star` b x let vbind0_rewrite (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: normal (t_of (vdep a (vbind0_payload a t b)))) : Tot t = snd (dsnd x) [@@__steel_reduce__; __reduce__] let vbind0 (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop = a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b let vbind_hp // necessary to hide the attribute on hp_of (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot (slprop u#1) = hp_of (vbind0 a t b) let vbind_sel // same for hp_sel (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot (selector t (vbind_hp a t b)) = sel_of (vbind0 a t b) [@@__steel_reduce__] let vbind' (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot vprop' = { hp = vbind_hp a t b; t = t; sel = vbind_sel a t b; } [@@__steel_reduce__] let vbind (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop = VUnit (vbind' a t b) let intro_vbind (#opened: _) (a: vprop) (b' : vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : SteelGhost unit opened (a `star` b') (fun _ -> vbind a t b) (fun h -> t_of b' == t /\ b' == b (h a)) (fun h _ h' -> t_of b' == t /\ b' == b (h a) /\ h' (vbind a t b) == h b' ) = intro_vpure (t == t_of b'); intro_vdep a (vpure (t == t_of b') `star` b') (vbind0_payload a t b); intro_vrewrite (a `vdep` vbind0_payload a t b) (vbind0_rewrite a t b); change_slprop_rel (vbind0 a t b) (vbind a t b) (fun x y -> x == y) (fun _ -> ()) let elim_vbind (#opened: _) (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : SteelGhost (Ghost.erased (t_of a)) opened (vbind a t b) (fun res -> a `star` b (Ghost.reveal res)) (fun h -> True) (fun h res h' -> h' a == Ghost.reveal res /\ t == t_of (b (Ghost.reveal res)) /\ h' (b (Ghost.reveal res)) == h (vbind a t b) ) = change_slprop_rel (vbind a t b) (vbind0 a t b) (fun x y -> x == y) (fun _ -> ()); elim_vrewrite (a `vdep` vbind0_payload a t b) (vbind0_rewrite a t b); let res = elim_vdep a (vbind0_payload a t b) in change_equal_slprop (vbind0_payload a t b (Ghost.reveal res)) (vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res)); elim_vpure (t == t_of (b (Ghost.reveal res))); res let (==) (#a:_) (x y: a) : prop = x == y let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma (requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2])) (ensures (hd1 == hd2 /\ tl1 == tl2)) [SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])] = L.lemma_snoc_unsnoc (hd1, tl1); L.lemma_snoc_unsnoc (hd2, tl2) [@"opaque_to_smt"] let unsnoc (#a: Type) (l: list a) : Pure (list a & a) (requires (Cons? l)) (ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l)) = L.lemma_unsnoc_snoc l; L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)]; L.unsnoc l let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' < L.length l)) = fst (unsnoc l) let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l) [@@"opaque_to_smt"] let snoc (#a: Type) (l: list a) (x: a) : Pure (list a) (requires True) (ensures (fun l' -> Cons? l' /\ unsnoc_hd l' == l /\ unsnoc_tl l' == x )) = let l' = L.snoc (l, x) in L.append_length l [x]; snoc_inj l (unsnoc_hd l') x (unsnoc_tl l'); l' let snoc_unsnoc (#a: Type) (l: list a) : Lemma (requires (Cons? l)) (ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l)) = () unfold let coerce (#a: Type) (x: a) (b: Type) : Pure b (requires (a == b)) (ensures (fun y -> a == b /\ x == y)) = x (* END library *) let t a = cllist_lvalue a let v (a: Type0) = list a let datas (#a: Type0) (l: v a) : Tot (list a) = l (* view from the tail *) let llist_fragment_tail_cons_data_refine (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (d: a) : Tot prop = d == unsnoc_tl (Ghost.reveal l) [@@ __steel_reduce__] let llist_fragment_tail_cons_lvalue_payload (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (c: ccell_lvalue a) : Tot vprop = vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l let ccell_is_lvalue_refine (a: Type) (c: ccell_ptrvalue a) : Tot prop = ccell_ptrvalue_is_null c == false [@@ __steel_reduce__ ] let llist_fragment_tail_cons_next_payload (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (ptail: ref (ccell_ptrvalue a)) : Tot vprop = vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l [@@ __steel_reduce__ ] let llist_fragment_tail_cons_rewrite (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) }) (x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l)))) : Tot (ref (ccell_ptrvalue a)) = let (| _, (| c, _ |) |) = x in ccell_next c let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop (requires True) (ensures (fun v -> t_of v == ref (ccell_ptrvalue a))) (decreases (Ghost.reveal (L.length l))) = if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) let llist_fragment_tail_eq (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Lemma (llist_fragment_tail l phead == ( if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) )) = assert_norm (llist_fragment_tail l phead == ( if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) )) let llist_fragment_tail_eq_cons (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Lemma (requires (Cons? l)) (ensures (Cons? l /\ llist_fragment_tail l phead == ( llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) ))) = llist_fragment_tail_eq l phead unfold let sel_llist_fragment_tail (#a:Type) (#p:vprop) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) }) : GTot (ref (ccell_ptrvalue a)) = coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a)) val intro_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened emp (fun _ -> llist_fragment_tail l phead) (fun _ -> Nil? l) (fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead) let intro_llist_fragment_tail_nil l phead = intro_vconst phead; change_equal_slprop (vconst phead) (llist_fragment_tail l phead) val elim_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_tail l phead) (fun _ -> emp) (fun _ -> Nil? l) (fun h _ _ -> sel_llist_fragment_tail l phead h == phead) let elim_llist_fragment_tail_nil l phead = change_equal_slprop (llist_fragment_tail l phead) (vconst phead); elim_vconst phead val intro_llist_fragment_tail_snoc (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (ptail: Ghost.erased (ref (ccell_ptrvalue a))) (tail: Ghost.erased (ccell_lvalue a)) : SteelGhost (Ghost.erased (list a)) opened (llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail)) (fun res -> llist_fragment_tail res phead) (fun h -> sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\ sel ptail h == Ghost.reveal tail ) (fun h res h' -> Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\ sel_llist_fragment_tail res phead h' == ccell_next tail ) #push-options "--z3rlimit 16" let intro_llist_fragment_tail_snoc #_ #a l phead ptail tail = let d = gget (vptr (ccell_data tail)) in let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l'); intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a); intro_vdep (vptr ptail `vrefine` ccell_is_lvalue_refine a) (vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l') (llist_fragment_tail_cons_lvalue_payload l'); change_equal_slprop (llist_fragment_tail l phead) (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead); intro_vdep (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead) (vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l') (llist_fragment_tail_cons_next_payload l'); intro_vrewrite_no_norm (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l') (llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)); llist_fragment_tail_eq_cons l' phead; change_equal_slprop (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)) (llist_fragment_tail l' phead); let g' = gget (llist_fragment_tail l' phead) in assert (Ghost.reveal g' == ccell_next tail); noop (); l' #pop-options [@@erasable] noeq type ll_unsnoc_t (a: Type) = { ll_unsnoc_l: list a; ll_unsnoc_ptail: ref (ccell_ptrvalue a); ll_unsnoc_tail: ccell_lvalue a; } val elim_llist_fragment_tail_snoc (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost (ll_unsnoc_t a) opened (llist_fragment_tail l phead) (fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail)) (fun _ -> Cons? l) (fun h res h' -> Cons? l /\ Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\ sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\ sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\ sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\ sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail) ) #push-options "--z3rlimit 32" #restart-solver let elim_llist_fragment_tail_snoc #_ #a l phead = let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in llist_fragment_tail_eq_cons l0 phead; change_equal_slprop (llist_fragment_tail l phead) (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)); elim_vrewrite_no_norm (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0) (llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)); let ptail = elim_vdep (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead) (llist_fragment_tail_cons_next_payload l0) in let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in change_equal_slprop (llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail)) (vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0); let tail = elim_vdep (vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a) (llist_fragment_tail_cons_lvalue_payload l0) in elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a); let res = { ll_unsnoc_l = unsnoc_hd l0; ll_unsnoc_ptail = Ghost.reveal ptail0; ll_unsnoc_tail = Ghost.reveal tail; } in change_equal_slprop (vptr (Ghost.reveal ptail0)) (vptr res.ll_unsnoc_ptail); change_equal_slprop (llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail)) (vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0); elim_vrefine (vptr (ccell_data res.ll_unsnoc_tail)) (llist_fragment_tail_cons_data_refine l0); change_equal_slprop (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead) (llist_fragment_tail res.ll_unsnoc_l phead); res #pop-options let rec llist_fragment_tail_append (#opened: _) (#a: Type) (phead0: ref (ccell_ptrvalue a)) (l1: Ghost.erased (list a)) (phead1: Ghost.erased (ref (ccell_ptrvalue a))) (l2: Ghost.erased (list a)) : SteelGhost (Ghost.erased (list a)) opened (llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1) (fun res -> llist_fragment_tail res phead0) (fun h -> Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h ) (fun h res h' -> Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\ (sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h ) (decreases (L.length (Ghost.reveal l2))) = let g1 = gget (llist_fragment_tail l1 phead0) in assert (Ghost.reveal phead1 == Ghost.reveal g1); if Nil? l2 then begin L.append_l_nil (Ghost.reveal l1); elim_llist_fragment_tail_nil l2 phead1; l1 end else begin let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d]; let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail end let queue_tail_refine (#a: Type) (tail1: ref (ccell_ptrvalue a)) (tail2: ref (ccell_ptrvalue a)) (tl: normal (t_of (vptr tail2))) : Tot prop = ccell_ptrvalue_is_null tl == true /\ tail1 == tail2 [@@__steel_reduce__] let queue_tail_dep2 (#a: Type) (x: t a) (l: Ghost.erased (list a)) (tail1: t_of (llist_fragment_tail l (cllist_head x))) (tail2: ref (ccell_ptrvalue a)) : Tot vprop = vptr tail2 `vrefine` queue_tail_refine tail1 tail2 [@@__steel_reduce__] let queue_tail_dep1 (#a: Type) (x: t a) (l: Ghost.erased (list a)) (tail1: t_of (llist_fragment_tail l (cllist_head x))) : Tot vprop = vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1 [@@__steel_reduce__; __reduce__] let queue_tail (#a: Type) (x: t a) (l: Ghost.erased (list a)) : Tot vprop = llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l val intro_queue_tail (#opened: _) (#a: Type) (x: t a) (l: Ghost.erased (list a)) (tail: ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail) (fun _ -> queue_tail x l) (fun h -> sel_llist_fragment_tail l (cllist_head x) h == tail /\ sel (cllist_tail x) h == tail /\ ccell_ptrvalue_is_null (sel tail h) ) (fun _ _ _ -> True) let intro_queue_tail x l tail = intro_vrefine (vptr tail) (queue_tail_refine tail tail); intro_vdep2 (vptr (cllist_tail x)) (vptr tail `vrefine` queue_tail_refine tail tail) tail (queue_tail_dep2 x l tail); intro_vdep2 (llist_fragment_tail l (cllist_head x)) (vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail) tail (queue_tail_dep1 x l) val elim_queue_tail (#opened: _) (#a: Type) (x: t a) (l: Ghost.erased (list a)) : SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened (queue_tail x l) (fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail) (fun h -> True) (fun _ tail h -> sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\ sel (cllist_tail x) h == Ghost.reveal tail /\ ccell_ptrvalue_is_null (h (vptr tail)) ) let elim_queue_tail #_ #a x l = let tail0 = elim_vdep (llist_fragment_tail l (cllist_head x)) (queue_tail_dep1 x l) in let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in change_equal_slprop (queue_tail_dep1 x l (Ghost.reveal tail0)) (vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0); let tail2 = elim_vdep (vptr (cllist_tail x)) (queue_tail_dep2 x l tail0) in let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in change_equal_slprop (queue_tail_dep2 x l tail0 (Ghost.reveal tail2)) (vptr tail3 `vrefine` queue_tail_refine tail0 tail3); elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3); change_equal_slprop (vptr tail3) (vptr tail); tail (* view from the head *) let llist_fragment_head_data_refine (#a: Type) (d: a) (c: vcell a) : Tot prop = c.vcell_data == d let llist_fragment_head_payload (#a: Type) (head: ccell_ptrvalue a) (d: a) (llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop)) (x: t_of (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine d))) : Tot vprop = llist_fragment_head (ccell_next (fst x)) (snd x).vcell_next let rec llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Tot vprop (decreases (Ghost.reveal l)) = if Nil? l then vconst (phead, head) else vbind (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l)))) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) (llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l)))) let t_of_llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Lemma (t_of (llist_fragment_head l phead head) == ref (ccell_ptrvalue a) & ccell_ptrvalue a) = () unfold let sel_llist_fragment_head (#a:Type) (#p:vprop) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) (h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_head l phead head) /\ True) }) : GTot (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = coerce (h (llist_fragment_head l phead head)) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) val intro_llist_fragment_head_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost unit opened emp (fun _ -> llist_fragment_head l phead head) (fun _ -> Nil? l) (fun _ _ h' -> sel_llist_fragment_head l phead head h' == (phead, head))
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "CQueue.LList.fsti.checked" ], "interface_file": true, "source_file": "CQueue.fst" }
[ { "abbrev": false, "full_module": "CQueue.LList", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: FStar.Ghost.erased (Prims.list a) -> phead: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) -> head: CQueue.Cell.ccell_ptrvalue a -> Steel.Effect.Atomic.SteelGhost Prims.unit
Steel.Effect.Atomic.SteelGhost
[]
[]
[ "Steel.Memory.inames", "FStar.Ghost.erased", "Prims.list", "Steel.Reference.ref", "CQueue.Cell.ccell_ptrvalue", "Steel.Effect.Atomic.change_equal_slprop", "CQueue.vconst", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "CQueue.llist_fragment_head", "Prims.unit", "CQueue.intro_vconst" ]
[]
false
true
false
false
false
let intro_llist_fragment_head_nil l phead head =
intro_vconst (phead, head); change_equal_slprop (vconst (phead, head)) (llist_fragment_head l phead head)
false
CQueue.fst
CQueue.intro_llist_fragment_tail_nil
val intro_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened emp (fun _ -> llist_fragment_tail l phead) (fun _ -> Nil? l) (fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
val intro_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened emp (fun _ -> llist_fragment_tail l phead) (fun _ -> Nil? l) (fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil l phead = intro_vconst phead; change_equal_slprop (vconst phead) (llist_fragment_tail l phead)
{ "file_name": "share/steel/examples/steel/CQueue.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 33, "end_line": 445, "start_col": 0, "start_line": 439 }
module CQueue open CQueue.LList #set-options "--ide_id_info_off" //Re-define squash, since this module explicitly //replies on proving equalities of the form `t_of v == squash p` //which are delicate in the presence of optimizations that //unfold `Prims.squash (p /\ q)`to _:unit{p /\ q} //See Issue #2496 let squash (p:Type u#a) : Type0 = squash p (* BEGIN library *) let intro_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: (t_of v) -> GTot t) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v)) = intro_vrewrite v f let elim_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened (vrewrite v f) (fun _ -> v) (fun _ -> True) (fun h _ h' -> h (vrewrite v f) == f (h' v)) = elim_vrewrite v f let vconst_sel (#a: Type) (x: a) : Tot (selector a (hp_of emp)) = fun _ -> x [@@ __steel_reduce__] let vconst' (#a: Type) (x: a) : GTot vprop' = { hp = hp_of emp; t = a; sel = vconst_sel x; } [@@ __steel_reduce__] let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x) let intro_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened emp (fun _ -> vconst x) (fun _ -> True) (fun _ _ h' -> h' (vconst x) == x) = change_slprop_rel emp (vconst x) (fun _ y -> y == x) (fun _ -> ()) let elim_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened (vconst x) (fun _ -> emp) (fun _ -> True) (fun h _ _ -> h (vconst x) == x) = change_slprop_rel (vconst x) emp (fun y _ -> y == x) (fun _ -> ()) let vpure_sel' (p: prop) : Tot (selector' (squash p) (Steel.Memory.pure p)) = fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m let vpure_sel (p: prop) : Tot (selector (squash p) (Steel.Memory.pure p)) = vpure_sel' p [@@ __steel_reduce__] let vpure' (p: prop) : GTot vprop' = { hp = Steel.Memory.pure p; t = squash p; sel = vpure_sel p; } [@@ __steel_reduce__] let vpure (p: prop) : Tot vprop = VUnit (vpure' p) let intro_vpure (#opened: _) (p: prop) : SteelGhost unit opened emp (fun _ -> vpure p) (fun _ -> p) (fun _ _ h' -> p) = change_slprop_rel emp (vpure p) (fun _ _ -> p) (fun m -> pure_interp p m) let elim_vpure (#opened: _) (p: prop) : SteelGhost unit opened (vpure p) (fun _ -> emp) (fun _ -> True) (fun _ _ _ -> p) = change_slprop_rel (vpure p) emp (fun _ _ -> p) (fun m -> pure_interp p m; reveal_emp (); intro_emp m) val intro_vdep2 (#opened:inames) (v: vprop) (q: vprop) (x: t_of v) (p: (t_of v -> Tot vprop)) : SteelGhost unit opened (v `star` q) (fun _ -> vdep v p) (requires (fun h -> q == p x /\ x == h v )) (ensures (fun h _ h' -> let x2 = h' (vdep v p) in q == p (h v) /\ dfst x2 == (h v) /\ dsnd x2 == (h q) )) let intro_vdep2 v q x p = intro_vdep v q p let vbind0_payload (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: t_of a) : Tot vprop = vpure (t == t_of (b x)) `star` b x let vbind0_rewrite (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: normal (t_of (vdep a (vbind0_payload a t b)))) : Tot t = snd (dsnd x) [@@__steel_reduce__; __reduce__] let vbind0 (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop = a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b let vbind_hp // necessary to hide the attribute on hp_of (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot (slprop u#1) = hp_of (vbind0 a t b) let vbind_sel // same for hp_sel (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot (selector t (vbind_hp a t b)) = sel_of (vbind0 a t b) [@@__steel_reduce__] let vbind' (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot vprop' = { hp = vbind_hp a t b; t = t; sel = vbind_sel a t b; } [@@__steel_reduce__] let vbind (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop = VUnit (vbind' a t b) let intro_vbind (#opened: _) (a: vprop) (b' : vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : SteelGhost unit opened (a `star` b') (fun _ -> vbind a t b) (fun h -> t_of b' == t /\ b' == b (h a)) (fun h _ h' -> t_of b' == t /\ b' == b (h a) /\ h' (vbind a t b) == h b' ) = intro_vpure (t == t_of b'); intro_vdep a (vpure (t == t_of b') `star` b') (vbind0_payload a t b); intro_vrewrite (a `vdep` vbind0_payload a t b) (vbind0_rewrite a t b); change_slprop_rel (vbind0 a t b) (vbind a t b) (fun x y -> x == y) (fun _ -> ()) let elim_vbind (#opened: _) (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : SteelGhost (Ghost.erased (t_of a)) opened (vbind a t b) (fun res -> a `star` b (Ghost.reveal res)) (fun h -> True) (fun h res h' -> h' a == Ghost.reveal res /\ t == t_of (b (Ghost.reveal res)) /\ h' (b (Ghost.reveal res)) == h (vbind a t b) ) = change_slprop_rel (vbind a t b) (vbind0 a t b) (fun x y -> x == y) (fun _ -> ()); elim_vrewrite (a `vdep` vbind0_payload a t b) (vbind0_rewrite a t b); let res = elim_vdep a (vbind0_payload a t b) in change_equal_slprop (vbind0_payload a t b (Ghost.reveal res)) (vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res)); elim_vpure (t == t_of (b (Ghost.reveal res))); res let (==) (#a:_) (x y: a) : prop = x == y let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma (requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2])) (ensures (hd1 == hd2 /\ tl1 == tl2)) [SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])] = L.lemma_snoc_unsnoc (hd1, tl1); L.lemma_snoc_unsnoc (hd2, tl2) [@"opaque_to_smt"] let unsnoc (#a: Type) (l: list a) : Pure (list a & a) (requires (Cons? l)) (ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l)) = L.lemma_unsnoc_snoc l; L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)]; L.unsnoc l let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' < L.length l)) = fst (unsnoc l) let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l) [@@"opaque_to_smt"] let snoc (#a: Type) (l: list a) (x: a) : Pure (list a) (requires True) (ensures (fun l' -> Cons? l' /\ unsnoc_hd l' == l /\ unsnoc_tl l' == x )) = let l' = L.snoc (l, x) in L.append_length l [x]; snoc_inj l (unsnoc_hd l') x (unsnoc_tl l'); l' let snoc_unsnoc (#a: Type) (l: list a) : Lemma (requires (Cons? l)) (ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l)) = () unfold let coerce (#a: Type) (x: a) (b: Type) : Pure b (requires (a == b)) (ensures (fun y -> a == b /\ x == y)) = x (* END library *) let t a = cllist_lvalue a let v (a: Type0) = list a let datas (#a: Type0) (l: v a) : Tot (list a) = l (* view from the tail *) let llist_fragment_tail_cons_data_refine (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (d: a) : Tot prop = d == unsnoc_tl (Ghost.reveal l) [@@ __steel_reduce__] let llist_fragment_tail_cons_lvalue_payload (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (c: ccell_lvalue a) : Tot vprop = vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l let ccell_is_lvalue_refine (a: Type) (c: ccell_ptrvalue a) : Tot prop = ccell_ptrvalue_is_null c == false [@@ __steel_reduce__ ] let llist_fragment_tail_cons_next_payload (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (ptail: ref (ccell_ptrvalue a)) : Tot vprop = vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l [@@ __steel_reduce__ ] let llist_fragment_tail_cons_rewrite (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) }) (x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l)))) : Tot (ref (ccell_ptrvalue a)) = let (| _, (| c, _ |) |) = x in ccell_next c let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop (requires True) (ensures (fun v -> t_of v == ref (ccell_ptrvalue a))) (decreases (Ghost.reveal (L.length l))) = if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) let llist_fragment_tail_eq (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Lemma (llist_fragment_tail l phead == ( if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) )) = assert_norm (llist_fragment_tail l phead == ( if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) )) let llist_fragment_tail_eq_cons (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Lemma (requires (Cons? l)) (ensures (Cons? l /\ llist_fragment_tail l phead == ( llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) ))) = llist_fragment_tail_eq l phead unfold let sel_llist_fragment_tail (#a:Type) (#p:vprop) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) }) : GTot (ref (ccell_ptrvalue a)) = coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a)) val intro_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened emp (fun _ -> llist_fragment_tail l phead) (fun _ -> Nil? l) (fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "CQueue.LList.fsti.checked" ], "interface_file": true, "source_file": "CQueue.fst" }
[ { "abbrev": false, "full_module": "CQueue.LList", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: FStar.Ghost.erased (Prims.list a) -> phead: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) -> Steel.Effect.Atomic.SteelGhost Prims.unit
Steel.Effect.Atomic.SteelGhost
[]
[]
[ "Steel.Memory.inames", "FStar.Ghost.erased", "Prims.list", "Steel.Reference.ref", "CQueue.Cell.ccell_ptrvalue", "Steel.Effect.Atomic.change_equal_slprop", "CQueue.vconst", "CQueue.llist_fragment_tail", "Prims.unit", "CQueue.intro_vconst" ]
[]
false
true
false
false
false
let intro_llist_fragment_tail_nil l phead =
intro_vconst phead; change_equal_slprop (vconst phead) (llist_fragment_tail l phead)
false
LList2.fst
LList2.init
val init (#v: Ghost.erased (scalar_t (ptr cell))) (r: ref (scalar (ptr cell))) : ST unit (pts_to r v) (fun _ -> pllist r []) (full (scalar (ptr cell)) v) (fun _ -> True)
val init (#v: Ghost.erased (scalar_t (ptr cell))) (r: ref (scalar (ptr cell))) : ST unit (pts_to r v) (fun _ -> pllist r []) (full (scalar (ptr cell)) v) (fun _ -> True)
let init (#v: Ghost.erased (scalar_t (ptr cell))) (r: ref (scalar (ptr cell))) : ST unit (pts_to r v) (fun _ -> pllist r []) (full (scalar (ptr cell)) v) (fun _ -> True) = noop (); rewrite (llist_nil (null _)) (llist (null _) []); pllist_put r (null _)
{ "file_name": "share/steel/examples/steelc/LList2.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 23, "end_line": 196, "start_col": 0, "start_line": 186 }
module LList2 open Steel.ST.GenElim open Steel.ST.C.Types open Steel.ST.C.Types.Struct.Aux open Steel.ST.C.Types.UserStruct // hides Struct module U32 = FStar.UInt32 noeq type cell_t = { hd: scalar_t U32.t; tl: scalar_t (ptr_gen cell_t); } noextract inline_for_extraction [@@ norm_field_attr] let cell_struct_def : struct_def cell_t = let fields = FStar.Set.add "hd" (FStar.Set.singleton "tl") in let field_desc : field_description_gen_t (field_t fields) = { fd_nonempty = nonempty_set_nonempty_type "hd" fields; fd_type = (fun (n: field_t fields) -> match n with "hd" -> scalar_t U32.t | "tl" -> scalar_t (ptr_gen cell_t)); fd_typedef = (fun (n: field_t fields) -> match n with "hd" -> scalar U32.t | "tl" -> scalar (ptr_gen cell_t)); } in { fields = fields; field_desc = field_desc; mk = (fun f -> Mkcell_t (f "hd") (f "tl")); get = (fun x (f: field_t fields) -> match f with "hd" -> x.hd | "tl" -> x.tl); get_mk = (fun _ _ -> ()); extensionality = (fun s1 s2 phi -> phi "hd"; phi "tl"); } noextract inline_for_extraction [@@ norm_field_attr] let cell = struct_typedef cell_struct_def [@@__reduce__] let llist_nil (p: ptr cell) : Tot vprop = pure (p == null _) [@@__reduce__] let llist_cons (p: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) (llist: (ptr cell -> (l: Ghost.erased (list U32.t) { List.Tot.length l < List.Tot.length (a :: q) }) -> Tot vprop)) : Tot vprop = exists_ (fun (p1: ref cell) -> exists_ (fun (p2: ptr cell) -> pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar p2 }) `star` llist p2 q `star` freeable p1 `star` pure (p == p1) )) let rec llist (p: ptr cell) (l: Ghost.erased (list U32.t)) : Tot vprop (decreases (List.Tot.length l)) = match Ghost.reveal l with | [] -> llist_nil p | a :: q -> llist_cons p a q llist let intro_llist_cons (#opened: _) (p1: ref cell) (#v1: Ghost.erased (typeof cell)) (p2: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) : STGhost unit opened (pts_to p1 v1 `star` llist p2 q `star` freeable p1 ) (fun _ -> llist p1 (a :: q)) (Ghost.reveal v1 == ({ hd = mk_scalar a; tl = mk_scalar p2 })) (fun _ -> True) = noop (); rewrite_with_tactic (llist_cons p1 a q llist) (llist p1 (a :: q)) let elim_llist_cons (#opened: _) (p1: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) : STGhostT (p2: Ghost.erased (ptr cell) { ~ (p1 == null _) }) opened (llist p1 (a :: q)) (fun p2 -> pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar (Ghost.reveal p2) }) `star` llist p2 q `star` freeable p1 ) = rewrite_with_tactic (llist p1 (a :: q)) (llist_cons p1 a q llist); let _ = gen_elim () in let p2' = vpattern_erased (fun x -> llist x q) in let p2 : (p2: Ghost.erased (ptr cell) { ~ (p1 == null _) }) = p2' in vpattern_rewrite (fun x -> llist x q) p2; rewrite (pts_to _ _) (pts_to _ _); rewrite (freeable _) (freeable _); _ [@@__reduce__] let pllist0 (p: ref (scalar (ptr cell))) (l: Ghost.erased (list U32.t)) : Tot vprop = exists_ (fun (pc: ptr cell) -> pts_to p (mk_scalar pc) `star` llist pc l ) let pllist (p: ref (scalar (ptr cell))) (l: Ghost.erased (list U32.t)) : Tot vprop = pllist0 p l let pllist_get (#l: Ghost.erased (list U32.t)) (p: ref (scalar (ptr cell))) : STT (ptr cell) (pllist p l) (fun pc -> pts_to p (mk_scalar (Ghost.reveal pc)) `star` llist pc l) = rewrite (pllist p l) (pllist0 p l); let _ = gen_elim () in let pc = read p in vpattern_rewrite (fun x -> llist x l) pc; return pc let pllist_put (#v: Ghost.erased (scalar_t (ptr cell))) (#l: Ghost.erased (list U32.t)) (p: ref (scalar (ptr cell))) (pc: ptr cell) : ST unit (pts_to p v `star` llist pc l) (fun _ -> pllist p l) (full (scalar (ptr cell)) v) (fun _ -> True) = write p pc; rewrite (pllist0 p l) (pllist p l) let push (#l: Ghost.erased (list U32.t)) (a: U32.t) (p: ref (scalar (ptr cell))) : STT bool (pllist p l) (fun b -> pllist p (if b then a :: l else l)) = let c = alloc cell in if is_null c then begin rewrite (pts_to_or_null _ _) emp; rewrite (freeable_or_null _) emp; return false end else begin rewrite (pts_to_or_null _ _) (pts_to c (uninitialized cell)); rewrite (freeable_or_null c) (freeable c); let p_tl = pllist_get p in let c_hd = struct_field c "hd" in let c_tl = struct_field c "tl" in write c_hd a; write c_tl p_tl; unstruct_field c "tl" c_tl; unstruct_field c "hd" c_hd; intro_llist_cons c p_tl a l; pllist_put p c; drop (has_struct_field c "hd" _); drop (has_struct_field _ _ _); return true end let pop (#l: Ghost.erased (list U32.t)) (p: ref (scalar (ptr cell))) (sq: squash (Cons? l)) : ST U32.t (pllist p l) (fun _ -> pllist p (List.Tot.tl l)) (True) (fun res -> res == List.Tot.hd l) = rewrite (pllist p l) (pllist p (List.Tot.hd l :: List.Tot.tl l)); let c = pllist_get p in let _ = elim_llist_cons c (List.Tot.hd l) (List.Tot.tl l) in let c_hd = struct_field c "hd" in let c_tl = struct_field c "tl" in let res = read c_hd in let p_tl = read c_tl in vpattern_rewrite (fun x -> llist x _) p_tl; unstruct_field c "tl" c_tl; unstruct_field c "hd" c_hd; free c; pllist_put p p_tl; drop (has_struct_field c "hd" _); drop (has_struct_field _ _ _); return res
{ "checked_file": "/", "dependencies": [ "Steel.ST.GenElim.fsti.checked", "Steel.ST.C.Types.UserStruct.fsti.checked", "Steel.ST.C.Types.Struct.Aux.fsti.checked", "Steel.ST.C.Types.fst.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LList2.fst" }
[ { "abbrev": false, "full_module": "Steel.ST.C.Types.UserStruct // hides Struct", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.ST.C.Types.UserStruct", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types.Struct.Aux", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Steel.ST.C.Types.Base.ref (Steel.ST.C.Types.Scalar.scalar (Steel.ST.C.Types.Base.ptr LList2.cell )) -> Steel.ST.Effect.ST Prims.unit
Steel.ST.Effect.ST
[]
[]
[ "FStar.Ghost.erased", "Steel.ST.C.Types.Scalar.scalar_t", "Steel.ST.C.Types.Base.ptr", "LList2.cell_t", "LList2.cell", "Steel.ST.C.Types.Base.ref", "Steel.ST.C.Types.Scalar.scalar", "LList2.pllist_put", "FStar.Ghost.hide", "Prims.list", "FStar.UInt32.t", "Prims.Nil", "Steel.ST.C.Types.Base.null", "Prims.unit", "Steel.ST.Util.rewrite", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "LList2.llist_nil", "LList2.llist", "Steel.ST.Util.noop", "Steel.ST.C.Types.Base.pts_to", "LList2.pllist", "Steel.Effect.Common.vprop", "Steel.ST.C.Types.Base.full", "FStar.Ghost.reveal", "Prims.l_True" ]
[]
false
true
false
false
false
let init (#v: Ghost.erased (scalar_t (ptr cell))) (r: ref (scalar (ptr cell))) : ST unit (pts_to r v) (fun _ -> pllist r []) (full (scalar (ptr cell)) v) (fun _ -> True) =
noop (); rewrite (llist_nil (null _)) (llist (null _) []); pllist_put r (null _)
false
CoreCrypto.fst
CoreCrypto.aeadRealIVSize
val aeadRealIVSize : a: CoreCrypto.aead_cipher -> Prims.int
let aeadRealIVSize (a:aead_cipher) = 12
{ "file_name": "ucontrib/CoreCrypto/fst/CoreCrypto.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 86, "start_col": 0, "start_line": 86 }
(* 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 CoreCrypto open Platform.Bytes (* ------------ Hashing ------------ *) type hash_alg = | MD5 | SHA1 | SHA224 | SHA256 | SHA384 | SHA512 let hashSize = function | MD5 -> 16 | SHA1 -> 20 | SHA224 -> 28 | SHA256 -> 32 | SHA384 -> 48 | SHA512 -> 64 (* These implementations are not pure; to be upgraded! *) assume val hash : alg:hash_alg -> bytes -> Tot (h:bytes{length h = hashSize alg}) assume val hmac : alg:hash_alg -> bytes -> bytes -> Tot (h:bytes{length h = hashSize alg}) (* Digest functions *) assume type hash_ctx : Type0 (* SI: or assume_new_abstract_type?*) assume val digest_create : hash_alg -> EXT hash_ctx assume val digest_update : hash_ctx -> bytes -> EXT unit assume val digest_final : hash_ctx -> EXT bytes (* --------------------------- *) type sig_alg = | RSASIG | DSA | ECDSA | RSAPSS type block_cipher = | AES_128_CBC | AES_256_CBC | TDES_EDE_CBC type stream_cipher = | RC4_128 type rsa_padding = | Pad_none | Pad_PKCS1 (* NB these constant functions must *exactly* match those in the trusted CoreCrypto.ml. We should compile them instead! *) let blockSize = function | TDES_EDE_CBC -> 8 | AES_128_CBC -> 16 | AES_256_CBC -> 16 (* Authenticated Encryption for TLS. Note that their AAD contents depends on the protocol version. *) type aead_cipher = | AES_128_GCM | AES_256_GCM | CHACHA20_POLY1305 | AES_128_CCM // "Counter with CBC-Message Authentication Code" | AES_256_CCM | AES_128_CCM_8 // variant with truncated 8-byte tags | AES_256_CCM_8 // the key materials consist of an encryption key, a static IV, and an authentication key. let aeadKeySize = function | AES_128_CCM -> 16 | AES_128_CCM_8 -> 16 | AES_128_GCM -> 16 | AES_256_CCM -> 32 | AES_256_CCM_8 -> 32 | AES_256_GCM -> 32 | CHACHA20_POLY1305 -> 32
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Platform.Bytes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "CoreCrypto.fst" }
[ { "abbrev": false, "full_module": "Platform.Bytes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: CoreCrypto.aead_cipher -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "CoreCrypto.aead_cipher", "Prims.int" ]
[]
false
false
false
true
false
let aeadRealIVSize (a: aead_cipher) =
12
false
CoreCrypto.fst
CoreCrypto.hashSize
val hashSize : _: CoreCrypto.hash_alg -> Prims.int
let hashSize = function | MD5 -> 16 | SHA1 -> 20 | SHA224 -> 28 | SHA256 -> 32 | SHA384 -> 48 | SHA512 -> 64
{ "file_name": "ucontrib/CoreCrypto/fst/CoreCrypto.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 16, "end_line": 35, "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 CoreCrypto open Platform.Bytes (* ------------ Hashing ------------ *) type hash_alg = | MD5 | SHA1 | SHA224 | SHA256 | SHA384 | SHA512
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Platform.Bytes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "CoreCrypto.fst" }
[ { "abbrev": false, "full_module": "Platform.Bytes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
_: CoreCrypto.hash_alg -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "CoreCrypto.hash_alg", "Prims.int" ]
[]
false
false
false
true
false
let hashSize =
function | MD5 -> 16 | SHA1 -> 20 | SHA224 -> 28 | SHA256 -> 32 | SHA384 -> 48 | SHA512 -> 64
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.bv_of_binder
val bv_of_binder (b: binder) : bv
val bv_of_binder (b: binder) : bv
let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 65, "end_line": 25, "start_col": 0, "start_line": 25 }
(* 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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Stubs.Reflection.Types.binder -> FStar.Stubs.Reflection.Types.bv
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.V1.Data.__proj__Mkbinder_view__item__binder_bv", "FStar.Stubs.Reflection.V1.Builtins.inspect_binder", "FStar.Stubs.Reflection.Types.bv" ]
[]
false
false
false
true
false
let bv_of_binder (b: binder) : bv =
(inspect_binder b).binder_bv
false
CoreCrypto.fst
CoreCrypto.blockSize
val blockSize : _: CoreCrypto.block_cipher -> Prims.int
let blockSize = function | TDES_EDE_CBC -> 8 | AES_128_CBC -> 16 | AES_256_CBC -> 16
{ "file_name": "ucontrib/CoreCrypto/fst/CoreCrypto.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 22, "end_line": 61, "start_col": 0, "start_line": 58 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CoreCrypto open Platform.Bytes (* ------------ Hashing ------------ *) type hash_alg = | MD5 | SHA1 | SHA224 | SHA256 | SHA384 | SHA512 let hashSize = function | MD5 -> 16 | SHA1 -> 20 | SHA224 -> 28 | SHA256 -> 32 | SHA384 -> 48 | SHA512 -> 64 (* These implementations are not pure; to be upgraded! *) assume val hash : alg:hash_alg -> bytes -> Tot (h:bytes{length h = hashSize alg}) assume val hmac : alg:hash_alg -> bytes -> bytes -> Tot (h:bytes{length h = hashSize alg}) (* Digest functions *) assume type hash_ctx : Type0 (* SI: or assume_new_abstract_type?*) assume val digest_create : hash_alg -> EXT hash_ctx assume val digest_update : hash_ctx -> bytes -> EXT unit assume val digest_final : hash_ctx -> EXT bytes (* --------------------------- *) type sig_alg = | RSASIG | DSA | ECDSA | RSAPSS type block_cipher = | AES_128_CBC | AES_256_CBC | TDES_EDE_CBC type stream_cipher = | RC4_128 type rsa_padding = | Pad_none | Pad_PKCS1 (* NB these constant functions must *exactly* match those in the trusted CoreCrypto.ml. We should compile them instead! *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Platform.Bytes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "CoreCrypto.fst" }
[ { "abbrev": false, "full_module": "Platform.Bytes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
_: CoreCrypto.block_cipher -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "CoreCrypto.block_cipher", "Prims.int" ]
[]
false
false
false
true
false
let blockSize =
function | TDES_EDE_CBC -> 8 | AES_128_CBC -> 16 | AES_256_CBC -> 16
false
CoreCrypto.fst
CoreCrypto.aeadTagSize
val aeadTagSize : _: CoreCrypto.aead_cipher -> Prims.int
let aeadTagSize = function | AES_128_CCM_8 -> 8 | AES_256_CCM_8 -> 8 | AES_128_CCM -> 16 | AES_256_CCM -> 16 | AES_128_GCM -> 16 | AES_256_GCM -> 16 | CHACHA20_POLY1305 -> 16
{ "file_name": "ucontrib/CoreCrypto/fst/CoreCrypto.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 96, "start_col": 0, "start_line": 89 }
(* 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 CoreCrypto open Platform.Bytes (* ------------ Hashing ------------ *) type hash_alg = | MD5 | SHA1 | SHA224 | SHA256 | SHA384 | SHA512 let hashSize = function | MD5 -> 16 | SHA1 -> 20 | SHA224 -> 28 | SHA256 -> 32 | SHA384 -> 48 | SHA512 -> 64 (* These implementations are not pure; to be upgraded! *) assume val hash : alg:hash_alg -> bytes -> Tot (h:bytes{length h = hashSize alg}) assume val hmac : alg:hash_alg -> bytes -> bytes -> Tot (h:bytes{length h = hashSize alg}) (* Digest functions *) assume type hash_ctx : Type0 (* SI: or assume_new_abstract_type?*) assume val digest_create : hash_alg -> EXT hash_ctx assume val digest_update : hash_ctx -> bytes -> EXT unit assume val digest_final : hash_ctx -> EXT bytes (* --------------------------- *) type sig_alg = | RSASIG | DSA | ECDSA | RSAPSS type block_cipher = | AES_128_CBC | AES_256_CBC | TDES_EDE_CBC type stream_cipher = | RC4_128 type rsa_padding = | Pad_none | Pad_PKCS1 (* NB these constant functions must *exactly* match those in the trusted CoreCrypto.ml. We should compile them instead! *) let blockSize = function | TDES_EDE_CBC -> 8 | AES_128_CBC -> 16 | AES_256_CBC -> 16 (* Authenticated Encryption for TLS. Note that their AAD contents depends on the protocol version. *) type aead_cipher = | AES_128_GCM | AES_256_GCM | CHACHA20_POLY1305 | AES_128_CCM // "Counter with CBC-Message Authentication Code" | AES_256_CCM | AES_128_CCM_8 // variant with truncated 8-byte tags | AES_256_CCM_8 // the key materials consist of an encryption key, a static IV, and an authentication key. let aeadKeySize = function | AES_128_CCM -> 16 | AES_128_CCM_8 -> 16 | AES_128_GCM -> 16 | AES_256_CCM -> 32 | AES_256_CCM_8 -> 32 | AES_256_GCM -> 32 | CHACHA20_POLY1305 -> 32 let aeadRealIVSize (a:aead_cipher) = 12
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Platform.Bytes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "CoreCrypto.fst" }
[ { "abbrev": false, "full_module": "Platform.Bytes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
_: CoreCrypto.aead_cipher -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "CoreCrypto.aead_cipher", "Prims.int" ]
[]
false
false
false
true
false
let aeadTagSize =
function | AES_128_CCM_8 -> 8 | AES_256_CCM_8 -> 8 | AES_128_CCM -> 16 | AES_256_CCM -> 16 | AES_128_GCM -> 16 | AES_256_GCM -> 16 | CHACHA20_POLY1305 -> 16
false
PositiveRelaxed.fst
PositiveRelaxed.loop
val loop : p (S O)
val loop : p (S O)
let loop = bad (PSO (fun h -> bad (POd?.h h)))
{ "file_name": "examples/paradoxes/PositiveRelaxed.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 46, "end_line": 35, "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 PositiveRelaxed type nat = | O : nat | S : pre:nat -> nat (* First, this inductive shouldn't be accepted by the _current_ check *) (* Second, this inductive shouldn't be accepted by _any_ check *) #push-options "--__no_positivity" noeq type p : nat -> Type = | PSO : f:(p O -> Tot (p (S O))) -> p (S O) | POd : h:(p (S O)) -> p O #pop-options val bad : p (S O) -> Tot (p (S O)) let bad h = (PSO?.f h) (POd h)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "PositiveRelaxed.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
PositiveRelaxed.p (PositiveRelaxed.S PositiveRelaxed.O)
Prims.Tot
[ "total" ]
[]
[ "PositiveRelaxed.bad", "PositiveRelaxed.PSO", "PositiveRelaxed.p", "PositiveRelaxed.O", "PositiveRelaxed.__proj__POd__item__h", "PositiveRelaxed.S" ]
[]
false
false
false
true
false
let loop =
bad (PSO (fun h -> bad (POd?.h h)))
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.mk_binder
val mk_binder (bv: bv) (sort: typ) : binder
val mk_binder (bv: bv) (sort: typ) : binder
let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; }
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 3, "end_line": 42, "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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments?
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
bv: FStar.Stubs.Reflection.Types.bv -> sort: FStar.Stubs.Reflection.Types.typ -> FStar.Stubs.Reflection.Types.binder
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.bv", "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.V1.Builtins.pack_binder", "FStar.Stubs.Reflection.V1.Data.Mkbinder_view", "FStar.Stubs.Reflection.V1.Data.Q_Explicit", "Prims.Nil", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.Types.binder" ]
[]
false
false
false
true
false
let mk_binder (bv: bv) (sort: typ) : binder =
pack_binder ({ binder_bv = bv; binder_qual = Q_Explicit; binder_attrs = []; binder_sort = sort })
false
CoreCrypto.fst
CoreCrypto.ec_bytelen
val ec_bytelen: ec_curve -> Tot (n:nat{n <= 127})
val ec_bytelen: ec_curve -> Tot (n:nat{n <= 127})
let ec_bytelen = function | ECC_P256 -> 32 | ECC_P384 -> 48 | ECC_P521 -> 66 (* ceil(521/8) *) | ECC_X25519 -> 32 | ECC_X448 -> 56
{ "file_name": "ucontrib/CoreCrypto/fst/CoreCrypto.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 200, "start_col": 0, "start_line": 195 }
(* 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 CoreCrypto open Platform.Bytes (* ------------ Hashing ------------ *) type hash_alg = | MD5 | SHA1 | SHA224 | SHA256 | SHA384 | SHA512 let hashSize = function | MD5 -> 16 | SHA1 -> 20 | SHA224 -> 28 | SHA256 -> 32 | SHA384 -> 48 | SHA512 -> 64 (* These implementations are not pure; to be upgraded! *) assume val hash : alg:hash_alg -> bytes -> Tot (h:bytes{length h = hashSize alg}) assume val hmac : alg:hash_alg -> bytes -> bytes -> Tot (h:bytes{length h = hashSize alg}) (* Digest functions *) assume type hash_ctx : Type0 (* SI: or assume_new_abstract_type?*) assume val digest_create : hash_alg -> EXT hash_ctx assume val digest_update : hash_ctx -> bytes -> EXT unit assume val digest_final : hash_ctx -> EXT bytes (* --------------------------- *) type sig_alg = | RSASIG | DSA | ECDSA | RSAPSS type block_cipher = | AES_128_CBC | AES_256_CBC | TDES_EDE_CBC type stream_cipher = | RC4_128 type rsa_padding = | Pad_none | Pad_PKCS1 (* NB these constant functions must *exactly* match those in the trusted CoreCrypto.ml. We should compile them instead! *) let blockSize = function | TDES_EDE_CBC -> 8 | AES_128_CBC -> 16 | AES_256_CBC -> 16 (* Authenticated Encryption for TLS. Note that their AAD contents depends on the protocol version. *) type aead_cipher = | AES_128_GCM | AES_256_GCM | CHACHA20_POLY1305 | AES_128_CCM // "Counter with CBC-Message Authentication Code" | AES_256_CCM | AES_128_CCM_8 // variant with truncated 8-byte tags | AES_256_CCM_8 // the key materials consist of an encryption key, a static IV, and an authentication key. let aeadKeySize = function | AES_128_CCM -> 16 | AES_128_CCM_8 -> 16 | AES_128_GCM -> 16 | AES_256_CCM -> 32 | AES_256_CCM_8 -> 32 | AES_256_GCM -> 32 | CHACHA20_POLY1305 -> 32 let aeadRealIVSize (a:aead_cipher) = 12 // the ciphertext ends with an authentication tag let aeadTagSize = function | AES_128_CCM_8 -> 8 | AES_256_CCM_8 -> 8 | AES_128_CCM -> 16 | AES_256_CCM -> 16 | AES_128_GCM -> 16 | AES_256_GCM -> 16 | CHACHA20_POLY1305 -> 16 //16-09-12 added precise concrete spec, matching what we implement in low-level/crypto //16-09-12 for robustness, we should at least test it when using external crypto. assume val aead_encryptT: a: aead_cipher -> k: lbytes (aeadKeySize a) -> iv:lbytes (aeadRealIVSize a) -> ad:bytes -> plain:bytes -> GTot (lbytes (length plain + aeadTagSize a)) assume val aead_encrypt: a: aead_cipher -> k: lbytes (aeadKeySize a) -> iv:lbytes (aeadRealIVSize a) -> ad:bytes -> plain:bytes -> EXT (c:bytes {c = aead_encryptT a k iv ad plain}) assume val aead_decrypt: a: aead_cipher -> k: lbytes (aeadKeySize a) -> iv:lbytes (aeadRealIVSize a) -> ad:bytes -> cipher:bytes{length cipher >= aeadTagSize a} -> EXT (o:option (b:bytes{length b + aeadTagSize a = length cipher}) {forall (p:bytes). cipher = aead_encryptT a k iv ad p <==> (Some? o /\ Some?.v o == p) }) type rsa_key = { rsa_mod : bytes; rsa_pub_exp : bytes; rsa_prv_exp : option bytes; } type dsa_params = { dsa_p : bytes; dsa_q : bytes; dsa_g : bytes; } type dsa_key = { dsa_params : dsa_params; dsa_public : bytes; dsa_private : option bytes; } type dh_params = { dh_p : bytes; dh_g : bytes; dh_q : option bytes; safe_prime : bool; } type dh_key = { dh_params : dh_params; dh_public : bytes; dh_private : option bytes; } (* TODO: revisit the Tot annotations, switch to EXT when appropriate *) assume val block_encrypt : block_cipher -> bytes -> bytes -> bytes -> EXT bytes assume val block_decrypt : block_cipher -> bytes -> bytes -> bytes -> EXT bytes assume new type cipher_stream : Type0 assume val stream_encryptor : stream_cipher -> bytes -> EXT cipher_stream assume val stream_decryptor : stream_cipher -> bytes -> EXT cipher_stream assume val stream_process : cipher_stream -> bytes -> EXT bytes assume val stream_fini : cipher_stream -> EXT unit assume val random : l:nat -> EXT (lbytes l) assume val rsa_gen_key : int -> EXT (k:rsa_key{Some? k.rsa_prv_exp}) assume val rsa_encrypt : rsa_key -> rsa_padding -> bytes -> EXT bytes assume val rsa_decrypt : k:rsa_key{Some? k.rsa_prv_exp} -> rsa_padding -> bytes -> EXT (option bytes) assume val rsa_sign : option hash_alg -> k:rsa_key{Some? k.rsa_prv_exp} -> pss:bool -> bytes -> EXT bytes assume val rsa_verify : option hash_alg -> rsa_key -> pss:bool -> bytes -> bytes -> EXT bool assume val dsa_gen_key : int -> EXT (k:dsa_key{Some? k.dsa_private}) assume val dsa_sign : option hash_alg -> k:dsa_key{Some? k.dsa_private} -> bytes -> EXT bytes assume val dsa_verify : option hash_alg -> dsa_key -> bytes -> bytes -> Tot bool assume val dh_gen_params : int -> EXT dh_params assume val dh_gen_key : p:dh_params -> EXT (k:dh_key{Some? k.dh_private /\ k.dh_params = p /\ length k.dh_public <= length p.dh_p}) assume val dh_agreement : k:dh_key{Some? k.dh_private} -> bytes -> EXT bytes (* type ec_prime = { ecp_prime : string; ecp_order : string; ecp_a : string; ecp_b : string; ecp_gx : string; ecp_gy : string; ecp_bytelen : int; ecp_id : bytes; } *) type ec_curve = | ECC_P256 | ECC_P384 | ECC_P521 | ECC_X25519 | ECC_X448 (* Bytelen of field elements *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Platform.Bytes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "CoreCrypto.fst" }
[ { "abbrev": false, "full_module": "Platform.Bytes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
_: CoreCrypto.ec_curve -> n: Prims.nat{n <= 127}
Prims.Tot
[ "total" ]
[]
[ "CoreCrypto.ec_curve", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual" ]
[]
false
false
false
false
false
let ec_bytelen =
function | ECC_P256 -> 32 | ECC_P384 -> 48 | ECC_P521 -> 66 | ECC_X25519 -> 32 | ECC_X448 -> 56
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.type_of_binder
val type_of_binder (b: binder) : typ
val type_of_binder (b: binder) : typ
let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 53, "start_col": 0, "start_line": 52 }
(* 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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Stubs.Reflection.Types.binder -> FStar.Stubs.Reflection.Types.typ
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.V1.Data.__proj__Mkbinder_view__item__binder_sort", "FStar.Stubs.Reflection.V1.Builtins.inspect_binder", "FStar.Stubs.Reflection.Types.typ" ]
[]
false
false
false
true
false
let type_of_binder (b: binder) : typ =
(inspect_binder b).binder_sort
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.collect_app_ln
val collect_app_ln : term -> term * list argv
val collect_app_ln : term -> term * list argv
let collect_app_ln = collect_app_ln' []
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term * Prims.list FStar.Stubs.Reflection.V1.Data.argv
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V1.Derived.collect_app_ln'", "Prims.Nil", "FStar.Stubs.Reflection.V1.Data.argv" ]
[]
false
false
false
true
false
let collect_app_ln =
collect_app_ln' []
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.mk_implicit_binder
val mk_implicit_binder (bv: bv) (sort: typ) : binder
val mk_implicit_binder (bv: bv) (sort: typ) : binder
let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; }
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 3, "end_line": 50, "start_col": 0, "start_line": 44 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
bv: FStar.Stubs.Reflection.Types.bv -> sort: FStar.Stubs.Reflection.Types.typ -> FStar.Stubs.Reflection.Types.binder
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.bv", "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.V1.Builtins.pack_binder", "FStar.Stubs.Reflection.V1.Data.Mkbinder_view", "FStar.Stubs.Reflection.V1.Data.Q_Implicit", "Prims.Nil", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.Types.binder" ]
[]
false
false
false
true
false
let mk_implicit_binder (bv: bv) (sort: typ) : binder =
pack_binder ({ binder_bv = bv; binder_qual = Q_Implicit; binder_attrs = []; binder_sort = sort })
false
CoreCrypto.fst
CoreCrypto.aeadKeySize
val aeadKeySize : _: CoreCrypto.aead_cipher -> Prims.int
let aeadKeySize = function | AES_128_CCM -> 16 | AES_128_CCM_8 -> 16 | AES_128_GCM -> 16 | AES_256_CCM -> 32 | AES_256_CCM_8 -> 32 | AES_256_GCM -> 32 | CHACHA20_POLY1305 -> 32
{ "file_name": "ucontrib/CoreCrypto/fst/CoreCrypto.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 84, "start_col": 0, "start_line": 77 }
(* 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 CoreCrypto open Platform.Bytes (* ------------ Hashing ------------ *) type hash_alg = | MD5 | SHA1 | SHA224 | SHA256 | SHA384 | SHA512 let hashSize = function | MD5 -> 16 | SHA1 -> 20 | SHA224 -> 28 | SHA256 -> 32 | SHA384 -> 48 | SHA512 -> 64 (* These implementations are not pure; to be upgraded! *) assume val hash : alg:hash_alg -> bytes -> Tot (h:bytes{length h = hashSize alg}) assume val hmac : alg:hash_alg -> bytes -> bytes -> Tot (h:bytes{length h = hashSize alg}) (* Digest functions *) assume type hash_ctx : Type0 (* SI: or assume_new_abstract_type?*) assume val digest_create : hash_alg -> EXT hash_ctx assume val digest_update : hash_ctx -> bytes -> EXT unit assume val digest_final : hash_ctx -> EXT bytes (* --------------------------- *) type sig_alg = | RSASIG | DSA | ECDSA | RSAPSS type block_cipher = | AES_128_CBC | AES_256_CBC | TDES_EDE_CBC type stream_cipher = | RC4_128 type rsa_padding = | Pad_none | Pad_PKCS1 (* NB these constant functions must *exactly* match those in the trusted CoreCrypto.ml. We should compile them instead! *) let blockSize = function | TDES_EDE_CBC -> 8 | AES_128_CBC -> 16 | AES_256_CBC -> 16 (* Authenticated Encryption for TLS. Note that their AAD contents depends on the protocol version. *) type aead_cipher = | AES_128_GCM | AES_256_GCM | CHACHA20_POLY1305 | AES_128_CCM // "Counter with CBC-Message Authentication Code" | AES_256_CCM | AES_128_CCM_8 // variant with truncated 8-byte tags | AES_256_CCM_8 // the key materials consist of an encryption key, a static IV, and an authentication key.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Platform.Bytes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "CoreCrypto.fst" }
[ { "abbrev": false, "full_module": "Platform.Bytes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
_: CoreCrypto.aead_cipher -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "CoreCrypto.aead_cipher", "Prims.int" ]
[]
false
false
false
true
false
let aeadKeySize =
function | AES_128_CCM -> 16 | AES_128_CCM_8 -> 16 | AES_128_GCM -> 16 | AES_256_CCM -> 32 | AES_256_CCM_8 -> 32 | AES_256_GCM -> 32 | CHACHA20_POLY1305 -> 32
false
PositiveRelaxed.fst
PositiveRelaxed.bad
val bad : p (S O) -> Tot (p (S O))
val bad : p (S O) -> Tot (p (S O))
let bad h = (PSO?.f h) (POd h)
{ "file_name": "examples/paradoxes/PositiveRelaxed.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 30, "end_line": 32, "start_col": 0, "start_line": 32 }
(* 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 PositiveRelaxed type nat = | O : nat | S : pre:nat -> nat (* First, this inductive shouldn't be accepted by the _current_ check *) (* Second, this inductive shouldn't be accepted by _any_ check *) #push-options "--__no_positivity" noeq type p : nat -> Type = | PSO : f:(p O -> Tot (p (S O))) -> p (S O) | POd : h:(p (S O)) -> p O #pop-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "PositiveRelaxed.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
h: PositiveRelaxed.p (PositiveRelaxed.S PositiveRelaxed.O) -> PositiveRelaxed.p (PositiveRelaxed.S PositiveRelaxed.O)
Prims.Tot
[ "total" ]
[]
[ "PositiveRelaxed.p", "PositiveRelaxed.S", "PositiveRelaxed.O", "PositiveRelaxed.__proj__PSO__item__f", "PositiveRelaxed.POd" ]
[]
false
false
false
true
false
let bad h =
(PSO?.f h) (POd h)
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.mk_e_app
val mk_e_app (t: term) (args: list term) : Tot term
val mk_e_app (t: term) (args: list term) : Tot term
let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args)
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 80, "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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: FStar.Stubs.Reflection.Types.term -> args: Prims.list FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "Prims.list", "FStar.Reflection.V1.Derived.mk_app", "FStar.List.Tot.Base.map", "FStar.Stubs.Reflection.V1.Data.argv", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.V1.Data.aqualv", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V1.Data.Q_Explicit" ]
[]
false
false
false
true
false
let mk_e_app (t: term) (args: list term) : Tot term =
let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args)
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.u_unk
val u_unk:universe
val u_unk:universe
let u_unk : universe = pack_universe Uv_Unk
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 82, "start_col": 0, "start_line": 82 }
(* 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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Stubs.Reflection.Types.universe
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.V1.Builtins.pack_universe", "FStar.Stubs.Reflection.V1.Data.Uv_Unk" ]
[]
false
false
false
true
false
let u_unk:universe =
pack_universe Uv_Unk
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.fv_to_string
val fv_to_string (fv: fv) : string
val fv_to_string (fv: fv) : string
let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv)
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 62, "end_line": 122, "start_col": 0, "start_line": 122 }
(* 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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t')
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
fv: FStar.Stubs.Reflection.Types.fv -> Prims.string
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.fv", "FStar.Stubs.Reflection.V1.Builtins.implode_qn", "FStar.Stubs.Reflection.V1.Builtins.inspect_fv", "Prims.string" ]
[]
false
false
false
true
false
let fv_to_string (fv: fv) : string =
implode_qn (inspect_fv fv)
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.collect_arr_ln
val collect_arr_ln : typ -> list typ * comp
val collect_arr_ln : typ -> list typ * comp
let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 42, "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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: FStar.Stubs.Reflection.Types.typ -> Prims.list FStar.Stubs.Reflection.Types.typ * FStar.Stubs.Reflection.Types.comp
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.typ", "Prims.list", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.Types.comp", "FStar.Pervasives.Native.Mktuple2", "FStar.List.Tot.Base.map", "FStar.Reflection.V1.Derived.type_of_binder", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V1.Derived.collect_arr_ln_bs" ]
[]
false
false
false
true
false
let collect_arr_ln t =
let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.mk_strcat
val mk_strcat (t1 t2: term) : term
val mk_strcat (t1 t2: term) : term
let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2]
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 71, "end_line": 128, "start_col": 0, "start_line": 127 }
(* 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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V1.Derived.mk_e_app", "FStar.Stubs.Reflection.V1.Builtins.pack_ln", "FStar.Stubs.Reflection.V1.Data.Tv_FVar", "FStar.Stubs.Reflection.V1.Builtins.pack_fv", "Prims.Cons", "Prims.string", "Prims.Nil" ]
[]
false
false
false
true
false
let mk_strcat (t1 t2: term) : term =
mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2]
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.mk_stringlit
val mk_stringlit (s: string) : term
val mk_stringlit (s: string) : term
let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s))
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 125, "start_col": 0, "start_line": 124 }
(* 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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: Prims.string -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "Prims.string", "FStar.Stubs.Reflection.V1.Builtins.pack_ln", "FStar.Stubs.Reflection.V1.Data.Tv_Const", "FStar.Stubs.Reflection.V1.Data.C_String", "FStar.Stubs.Reflection.Types.term" ]
[]
false
false
false
true
false
let mk_stringlit (s: string) : term =
pack_ln (Tv_Const (C_String s))
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.collect_abs_ln
val collect_abs_ln : term -> list binder * term
val collect_abs_ln : term -> list binder * term
let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t')
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 30, "end_line": 120, "start_col": 0, "start_line": 118 }
(* 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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: FStar.Stubs.Reflection.Types.term -> Prims.list FStar.Stubs.Reflection.Types.binder * FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "Prims.list", "FStar.Stubs.Reflection.Types.binder", "FStar.Pervasives.Native.Mktuple2", "FStar.List.Tot.Base.rev", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V1.Derived.collect_abs'", "Prims.Nil" ]
[]
false
false
false
true
false
let collect_abs_ln t =
let bs, t' = collect_abs' [] t in (List.Tot.Base.rev bs, t')
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.collect_arr_ln_bs
val collect_arr_ln_bs : typ -> list binder * comp
val collect_arr_ln_bs : typ -> list binder * comp
let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c)
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 104, "start_col": 0, "start_line": 102 }
(* 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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: FStar.Stubs.Reflection.Types.typ -> Prims.list FStar.Stubs.Reflection.Types.binder * FStar.Stubs.Reflection.Types.comp
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.typ", "Prims.list", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.Types.comp", "FStar.Pervasives.Native.Mktuple2", "FStar.List.Tot.Base.rev", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V1.Derived.collect_arr'", "Prims.Nil", "FStar.Stubs.Reflection.V1.Builtins.pack_comp", "FStar.Stubs.Reflection.V1.Data.C_Total" ]
[]
false
false
false
true
false
let collect_arr_ln_bs t =
let bs, c = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c)
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.mk_cons_t
val mk_cons_t (ty h t: term) : term
val mk_cons_t (ty h t: term) : term
let mk_cons_t (ty h t : term) : term = mk_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [(ty, Q_Implicit); (h, Q_Explicit); (t, Q_Explicit)]
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 100, "end_line": 134, "start_col": 0, "start_line": 133 }
(* 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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s)) let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2] let mk_cons (h t : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
ty: FStar.Stubs.Reflection.Types.term -> h: FStar.Stubs.Reflection.Types.term -> t: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V1.Derived.mk_app", "FStar.Stubs.Reflection.V1.Builtins.pack_ln", "FStar.Stubs.Reflection.V1.Data.Tv_FVar", "FStar.Stubs.Reflection.V1.Builtins.pack_fv", "FStar.Reflection.Const.cons_qn", "Prims.Cons", "FStar.Stubs.Reflection.V1.Data.argv", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V1.Data.aqualv", "FStar.Stubs.Reflection.V1.Data.Q_Implicit", "FStar.Stubs.Reflection.V1.Data.Q_Explicit", "Prims.Nil" ]
[]
false
false
false
true
false
let mk_cons_t (ty h t: term) : term =
mk_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [(ty, Q_Implicit); (h, Q_Explicit); (t, Q_Explicit)]
false
Hacl.Spec.Curve25519.Field64.Definition.fst
Hacl.Spec.Curve25519.Field64.Definition.felem4
val felem4 : Type0
let felem4 = (uint64 * uint64 * uint64 * uint64)
{ "file_name": "code/curve25519/Hacl.Spec.Curve25519.Field64.Definition.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 10, "start_col": 0, "start_line": 10 }
module Hacl.Spec.Curve25519.Field64.Definition open Lib.Sequence open Lib.IntTypes module P = Spec.Curve25519 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
{ "checked_file": "/", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Impl.Curve25519.Lemmas.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Curve25519.Field64.Definition.fst" }
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "P" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Curve25519.Field64", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Curve25519.Field64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple4", "Lib.IntTypes.uint64" ]
[]
false
false
false
true
true
let felem4 =
(((uint64 * uint64) * uint64) * uint64)
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.inspect_ln_unascribe
val inspect_ln_unascribe (t: term) : tv: term_view{tv << t /\ notAscription tv}
val inspect_ln_unascribe (t: term) : tv: term_view{tv << t /\ notAscription tv}
let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 14, "end_line": 31, "start_col": 0, "start_line": 27 }
(* 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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: FStar.Stubs.Reflection.Types.term -> tv: FStar.Stubs.Reflection.V1.Data.term_view {tv << t /\ FStar.Stubs.Reflection.V1.Data.notAscription tv}
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V1.Builtins.inspect_ln", "FStar.Pervasives.Native.option", "Prims.bool", "FStar.Reflection.V1.Derived.inspect_ln_unascribe", "FStar.Stubs.Reflection.Types.comp", "FStar.Stubs.Reflection.V1.Data.term_view", "Prims.l_and", "Prims.precedes", "Prims.b2t", "FStar.Stubs.Reflection.V1.Data.notAscription" ]
[ "recursion" ]
false
false
false
false
false
let rec inspect_ln_unascribe (t: term) : tv: term_view{tv << t /\ notAscription tv} =
match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.mk_cons
val mk_cons (h t: term) : term
val mk_cons (h t: term) : term
let mk_cons (h t : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t]
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 56, "end_line": 131, "start_col": 0, "start_line": 130 }
(* 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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s)) let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
h: FStar.Stubs.Reflection.Types.term -> t: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V1.Derived.mk_e_app", "FStar.Stubs.Reflection.V1.Builtins.pack_ln", "FStar.Stubs.Reflection.V1.Data.Tv_FVar", "FStar.Stubs.Reflection.V1.Builtins.pack_fv", "FStar.Reflection.Const.cons_qn", "Prims.Cons", "Prims.Nil" ]
[]
false
false
false
true
false
let mk_cons (h t: term) : term =
mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t]
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.is_fvar
val is_fvar (t: term) (nm: string) : bool
val is_fvar (t: term) (nm: string) : bool
let is_fvar (t : term) (nm:string) : bool = match inspect_ln_unascribe t with | Tv_FVar fv | Tv_UInst fv _ -> implode_qn (inspect_fv fv) = nm | _ -> false
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 16, "end_line": 201, "start_col": 0, "start_line": 197 }
(* 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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s)) let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2] let mk_cons (h t : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t] let mk_cons_t (ty h t : term) : term = mk_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [(ty, Q_Implicit); (h, Q_Explicit); (t, Q_Explicit)] let rec mk_list (ts : list term) : term = match ts with | [] -> pack_ln (Tv_FVar (pack_fv nil_qn)) | t::ts -> mk_cons t (mk_list ts) let mktuple_n (ts : list term{List.Tot.Base.length ts <= 8}) : term = match List.Tot.Base.length ts with | 0 -> pack_ln (Tv_Const C_Unit) | 1 -> let [x] = ts in x | n -> begin let qn = match n with | 2 -> mktuple2_qn | 3 -> mktuple3_qn | 4 -> mktuple4_qn | 5 -> mktuple5_qn | 6 -> mktuple6_qn | 7 -> mktuple7_qn | 8 -> mktuple8_qn in mk_e_app (pack_ln (Tv_FVar (pack_fv qn))) ts end let destruct_tuple (t : term) : option (list term) = let head, args = collect_app_ln t in match inspect_ln head with | Tv_FVar fv -> if List.Tot.Base.mem (inspect_fv fv) [mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn; mktuple7_qn; mktuple8_qn] then Some (List.Tot.Base.concatMap (fun (t, q) -> match q with | Q_Explicit -> [t] | _ -> []) args) else None | _ -> None let mkpair (t1 t2 : term) : term = mktuple_n [t1;t2] let rec head (t : term) : term = match inspect_ln t with | Tv_Match t _ _ | Tv_Let _ _ _ _ t _ | Tv_Abs _ t | Tv_Refine _ _ t | Tv_App t _ | Tv_AscribedT t _ _ _ | Tv_AscribedC t _ _ _ -> head t | Tv_Unknown | Tv_Uvar _ _ | Tv_Const _ | Tv_Type _ | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_UInst _ _ | Tv_Arrow _ _ | Tv_Unsupp -> t (** Checks if a term `t` is equal to some FV (a top level name).
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: FStar.Stubs.Reflection.Types.term -> nm: Prims.string -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "Prims.string", "FStar.Reflection.V1.Derived.inspect_ln_unascribe", "FStar.Stubs.Reflection.Types.fv", "Prims.op_Equality", "FStar.Stubs.Reflection.V1.Builtins.implode_qn", "FStar.Stubs.Reflection.V1.Builtins.inspect_fv", "FStar.Stubs.Reflection.V1.Data.universes", "FStar.Stubs.Reflection.V1.Data.term_view", "Prims.bool" ]
[]
false
false
false
true
false
let is_fvar (t: term) (nm: string) : bool =
match inspect_ln_unascribe t with | Tv_FVar fv | Tv_UInst fv _ -> implode_qn (inspect_fv fv) = nm | _ -> false
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.binder_set_qual
val binder_set_qual (q: aqualv) (b: binder) : Tot binder
val binder_set_qual (q: aqualv) (b: binder) : Tot binder
let binder_set_qual (q:aqualv) (b:binder) : Tot binder = let bview = inspect_binder b in pack_binder {bview with binder_qual=q}
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 217, "start_col": 0, "start_line": 215 }
(* 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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s)) let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2] let mk_cons (h t : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t] let mk_cons_t (ty h t : term) : term = mk_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [(ty, Q_Implicit); (h, Q_Explicit); (t, Q_Explicit)] let rec mk_list (ts : list term) : term = match ts with | [] -> pack_ln (Tv_FVar (pack_fv nil_qn)) | t::ts -> mk_cons t (mk_list ts) let mktuple_n (ts : list term{List.Tot.Base.length ts <= 8}) : term = match List.Tot.Base.length ts with | 0 -> pack_ln (Tv_Const C_Unit) | 1 -> let [x] = ts in x | n -> begin let qn = match n with | 2 -> mktuple2_qn | 3 -> mktuple3_qn | 4 -> mktuple4_qn | 5 -> mktuple5_qn | 6 -> mktuple6_qn | 7 -> mktuple7_qn | 8 -> mktuple8_qn in mk_e_app (pack_ln (Tv_FVar (pack_fv qn))) ts end let destruct_tuple (t : term) : option (list term) = let head, args = collect_app_ln t in match inspect_ln head with | Tv_FVar fv -> if List.Tot.Base.mem (inspect_fv fv) [mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn; mktuple7_qn; mktuple8_qn] then Some (List.Tot.Base.concatMap (fun (t, q) -> match q with | Q_Explicit -> [t] | _ -> []) args) else None | _ -> None let mkpair (t1 t2 : term) : term = mktuple_n [t1;t2] let rec head (t : term) : term = match inspect_ln t with | Tv_Match t _ _ | Tv_Let _ _ _ _ t _ | Tv_Abs _ t | Tv_Refine _ _ t | Tv_App t _ | Tv_AscribedT t _ _ _ | Tv_AscribedC t _ _ _ -> head t | Tv_Unknown | Tv_Uvar _ _ | Tv_Const _ | Tv_Type _ | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_UInst _ _ | Tv_Arrow _ _ | Tv_Unsupp -> t (** Checks if a term `t` is equal to some FV (a top level name). Ignores universes and ascriptions. *) let is_fvar (t : term) (nm:string) : bool = match inspect_ln_unascribe t with | Tv_FVar fv | Tv_UInst fv _ -> implode_qn (inspect_fv fv) = nm | _ -> false (** Checks if a term `t` is equal to any FV (a top level name) from those given in the list. Ignores universes and ascriptions. *) let rec is_any_fvar (t : term) (nms:list string) : bool = match nms with | [] -> false | v::vs -> is_fvar t v || is_any_fvar t vs let is_uvar (t : term) : bool = match inspect_ln (head t) with | Tv_Uvar _ _ -> true | _ -> false
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
q: FStar.Stubs.Reflection.V1.Data.aqualv -> b: FStar.Stubs.Reflection.Types.binder -> FStar.Stubs.Reflection.Types.binder
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.V1.Data.aqualv", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.V1.Builtins.pack_binder", "FStar.Stubs.Reflection.V1.Data.Mkbinder_view", "FStar.Stubs.Reflection.V1.Data.__proj__Mkbinder_view__item__binder_bv", "FStar.Stubs.Reflection.V1.Data.__proj__Mkbinder_view__item__binder_attrs", "FStar.Stubs.Reflection.V1.Data.__proj__Mkbinder_view__item__binder_sort", "FStar.Stubs.Reflection.V1.Data.binder_view", "Prims.precedes", "FStar.Stubs.Reflection.V1.Builtins.inspect_binder" ]
[]
false
false
false
true
false
let binder_set_qual (q: aqualv) (b: binder) : Tot binder =
let bview = inspect_binder b in pack_binder ({ bview with binder_qual = q })
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.is_uvar
val is_uvar (t: term) : bool
val is_uvar (t: term) : bool
let is_uvar (t : term) : bool = match inspect_ln (head t) with | Tv_Uvar _ _ -> true | _ -> false
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 16, "end_line": 213, "start_col": 0, "start_line": 210 }
(* 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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s)) let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2] let mk_cons (h t : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t] let mk_cons_t (ty h t : term) : term = mk_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [(ty, Q_Implicit); (h, Q_Explicit); (t, Q_Explicit)] let rec mk_list (ts : list term) : term = match ts with | [] -> pack_ln (Tv_FVar (pack_fv nil_qn)) | t::ts -> mk_cons t (mk_list ts) let mktuple_n (ts : list term{List.Tot.Base.length ts <= 8}) : term = match List.Tot.Base.length ts with | 0 -> pack_ln (Tv_Const C_Unit) | 1 -> let [x] = ts in x | n -> begin let qn = match n with | 2 -> mktuple2_qn | 3 -> mktuple3_qn | 4 -> mktuple4_qn | 5 -> mktuple5_qn | 6 -> mktuple6_qn | 7 -> mktuple7_qn | 8 -> mktuple8_qn in mk_e_app (pack_ln (Tv_FVar (pack_fv qn))) ts end let destruct_tuple (t : term) : option (list term) = let head, args = collect_app_ln t in match inspect_ln head with | Tv_FVar fv -> if List.Tot.Base.mem (inspect_fv fv) [mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn; mktuple7_qn; mktuple8_qn] then Some (List.Tot.Base.concatMap (fun (t, q) -> match q with | Q_Explicit -> [t] | _ -> []) args) else None | _ -> None let mkpair (t1 t2 : term) : term = mktuple_n [t1;t2] let rec head (t : term) : term = match inspect_ln t with | Tv_Match t _ _ | Tv_Let _ _ _ _ t _ | Tv_Abs _ t | Tv_Refine _ _ t | Tv_App t _ | Tv_AscribedT t _ _ _ | Tv_AscribedC t _ _ _ -> head t | Tv_Unknown | Tv_Uvar _ _ | Tv_Const _ | Tv_Type _ | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_UInst _ _ | Tv_Arrow _ _ | Tv_Unsupp -> t (** Checks if a term `t` is equal to some FV (a top level name). Ignores universes and ascriptions. *) let is_fvar (t : term) (nm:string) : bool = match inspect_ln_unascribe t with | Tv_FVar fv | Tv_UInst fv _ -> implode_qn (inspect_fv fv) = nm | _ -> false (** Checks if a term `t` is equal to any FV (a top level name) from those given in the list. Ignores universes and ascriptions. *) let rec is_any_fvar (t : term) (nms:list string) : bool = match nms with | [] -> false | v::vs -> is_fvar t v || is_any_fvar t vs
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: FStar.Stubs.Reflection.Types.term -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V1.Builtins.inspect_ln", "FStar.Reflection.V1.Derived.head", "Prims.nat", "FStar.Stubs.Reflection.Types.ctx_uvar_and_subst", "FStar.Stubs.Reflection.V1.Data.term_view", "Prims.bool" ]
[]
false
false
false
true
false
let is_uvar (t: term) : bool =
match inspect_ln (head t) with | Tv_Uvar _ _ -> true | _ -> false
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.add_check_with
val add_check_with : vconfig -> sigelt -> Tot sigelt
val add_check_with : vconfig -> sigelt -> Tot sigelt
let add_check_with vcfg se = let attrs = sigelt_attrs se in let vcfg_t = embed_vconfig vcfg in let t = `(check_with (`#vcfg_t)) in set_sigelt_attrs (t :: attrs) se
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 225, "start_col": 0, "start_line": 221 }
(* 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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s)) let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2] let mk_cons (h t : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t] let mk_cons_t (ty h t : term) : term = mk_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [(ty, Q_Implicit); (h, Q_Explicit); (t, Q_Explicit)] let rec mk_list (ts : list term) : term = match ts with | [] -> pack_ln (Tv_FVar (pack_fv nil_qn)) | t::ts -> mk_cons t (mk_list ts) let mktuple_n (ts : list term{List.Tot.Base.length ts <= 8}) : term = match List.Tot.Base.length ts with | 0 -> pack_ln (Tv_Const C_Unit) | 1 -> let [x] = ts in x | n -> begin let qn = match n with | 2 -> mktuple2_qn | 3 -> mktuple3_qn | 4 -> mktuple4_qn | 5 -> mktuple5_qn | 6 -> mktuple6_qn | 7 -> mktuple7_qn | 8 -> mktuple8_qn in mk_e_app (pack_ln (Tv_FVar (pack_fv qn))) ts end let destruct_tuple (t : term) : option (list term) = let head, args = collect_app_ln t in match inspect_ln head with | Tv_FVar fv -> if List.Tot.Base.mem (inspect_fv fv) [mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn; mktuple7_qn; mktuple8_qn] then Some (List.Tot.Base.concatMap (fun (t, q) -> match q with | Q_Explicit -> [t] | _ -> []) args) else None | _ -> None let mkpair (t1 t2 : term) : term = mktuple_n [t1;t2] let rec head (t : term) : term = match inspect_ln t with | Tv_Match t _ _ | Tv_Let _ _ _ _ t _ | Tv_Abs _ t | Tv_Refine _ _ t | Tv_App t _ | Tv_AscribedT t _ _ _ | Tv_AscribedC t _ _ _ -> head t | Tv_Unknown | Tv_Uvar _ _ | Tv_Const _ | Tv_Type _ | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_UInst _ _ | Tv_Arrow _ _ | Tv_Unsupp -> t (** Checks if a term `t` is equal to some FV (a top level name). Ignores universes and ascriptions. *) let is_fvar (t : term) (nm:string) : bool = match inspect_ln_unascribe t with | Tv_FVar fv | Tv_UInst fv _ -> implode_qn (inspect_fv fv) = nm | _ -> false (** Checks if a term `t` is equal to any FV (a top level name) from those given in the list. Ignores universes and ascriptions. *) let rec is_any_fvar (t : term) (nms:list string) : bool = match nms with | [] -> false | v::vs -> is_fvar t v || is_any_fvar t vs let is_uvar (t : term) : bool = match inspect_ln (head t) with | Tv_Uvar _ _ -> true | _ -> false let binder_set_qual (q:aqualv) (b:binder) : Tot binder = let bview = inspect_binder b in pack_binder {bview with binder_qual=q} (** Set a vconfig for a sigelt *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
vcfg: FStar.VConfig.vconfig -> se: FStar.Stubs.Reflection.Types.sigelt -> FStar.Stubs.Reflection.Types.sigelt
Prims.Tot
[ "total" ]
[]
[ "FStar.VConfig.vconfig", "FStar.Stubs.Reflection.Types.sigelt", "FStar.Stubs.Reflection.V1.Builtins.set_sigelt_attrs", "Prims.Cons", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V1.Builtins.embed_vconfig", "Prims.list", "FStar.Stubs.Reflection.V1.Builtins.sigelt_attrs" ]
[]
false
false
false
true
false
let add_check_with vcfg se =
let attrs = sigelt_attrs se in let vcfg_t = embed_vconfig vcfg in let t = `(check_with (`#vcfg_t)) in set_sigelt_attrs (t :: attrs) se
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.flatten_name
val flatten_name : name -> Tot string
val flatten_name : name -> Tot string
let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 60, "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.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
ns: FStar.Stubs.Reflection.Types.name -> Prims.string
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.name", "Prims.string", "Prims.list", "Prims.op_Hat", "FStar.Reflection.V1.Derived.flatten_name" ]
[ "recursion" ]
false
false
false
true
false
let rec flatten_name ns =
match ns with | [] -> "" | [n] -> n | n :: ns -> n ^ "." ^ flatten_name ns
false